Re: Can I split&write data to each individual sheet?
From: Dave Peterson (ec35720_at_msn.com)
Date: 09/07/04
- Next message: Simon Lloyd: "Re: Can you fix this?? vbreadonly"
- Previous message: woolfm: "get more than 255 characters from text box"
- In reply to: Jack: "Re: Can I split&write data to each individual sheet?"
- Next in thread: Jack: "Re: Can I split&write data to each individual sheet?"
- Reply: Jack: "Re: Can I split&write data to each individual sheet?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 07 Sep 2004 08:01:00 -0500
This sounds like a problem that can be resolved in the newsgroup.
Did you try adding the validation checks into your code?
Jack wrote:
>
> Hi Dave,
> I know I'm taking too much time of yours. Sorry for beeing unsuccessfull
> again. I have changed the sheet name to the one I am using on all_data.xls
> and It looks like I am opening the correct workbook and worksheet allright
> but keep getting the error message at the command line:
> Set sh = bk2.Worksheets(cell.Offset(0, 1).Value)
> The problem may reside on the design/formats of the worksheets/cells I am
> using thus may I suggest that I send you the files again please? (if you
> kindly will provide me a valid email add.)
> Thank you
> Jack
>
> "Dave Peterson" <ec35720@msn.com> wrote in message
> news:413C7A47.929A131@msn.com...
> > Remember that all_data.xls has to be open before you start the macro. Is
> it?
> >
> > This version will yell at you if you don't have it open (remember to
> change the
> > sheet name to what you want).
> >
> > Option Explicit
> > Sub Tester1()
> > Dim wb1 As Workbook
> > Dim wk1 As Worksheet, bk2 As Workbook
> > Dim sh As Worksheet, cell As Range, rng As Range
> > Dim rng1 As Range, res As Variant
> >
> > Set wb1 = Nothing
> > On Error Resume Next
> > Set wb1 = Workbooks("all_data.xls")
> > On Error GoTo 0
> > If wb1 Is Nothing Then
> > MsgBox "all_data.xls isn't open!"
> > Exit Sub
> > End If
> >
> > Set wk1 = Nothing
> > On Error Resume Next
> > Set wk1 = wb1.Worksheets("sheet1")
> > On Error GoTo 0
> > If wk1 Is Nothing Then
> > MsgBox "all_data.xls doesn't have that sheet"
> > Exit Sub
> > End If
> >
> > Set bk2 = Workbooks("Reports.xls")
> > Set rng = wk1.Range(wk1.Cells(2, 1), wk1.Cells(2, 1).End(xlDown))
> > For Each cell In rng
> > Set sh = bk2.Worksheets(cell.Offset(0, 1).Value)
> > Set rng1 = sh.Range(sh.Cells(2, "H"), sh.Cells(2, "H").End(xlDown))
> > res = Application.Match(CLng(cell.Offset(0, 7)), rng1, 0)
> > If IsError(res) Then
> > cell.EntireRow.Copy _
> > Destination:=rng1.Offset( _
> > rng1.Rows.Count, 0).Resize(1, 1).EntireRow.Cells(1)
> > End If
> > Next cell
> >
> > End Sub
-- Dave Peterson ec35720@msn.com
- Next message: Simon Lloyd: "Re: Can you fix this?? vbreadonly"
- Previous message: woolfm: "get more than 255 characters from text box"
- In reply to: Jack: "Re: Can I split&write data to each individual sheet?"
- Next in thread: Jack: "Re: Can I split&write data to each individual sheet?"
- Reply: Jack: "Re: Can I split&write data to each individual sheet?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|