T
Tom Ogilvy
Is it possible using macros?
Yes, it should be possible.
Yes, it should be possible.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.

Martyn said:Hi Tom,
I used the code in the "Reports.xls" file with the All_data.xls file open
but
Received an Compile error "Invalid Outside Procedure" for the line
Set bk1 = Workbooks("All_data.xls")
Should the code reside on a seperate file?
Tom Ogilvy said:No, you need to put it in a procedure:
Sub Tester1()
Dim bk1 as workbook, bk2 as workbook
Dim sh as worksheet, cell as range, rng as Range
Dim rng1 as Range, res as Variant
set bk1 = Workbooks("All_data.xls")
set bk2 = workbooks("Reports.xls")
set rng = bk1.Range(bk1.Cells(2,1),bk1.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)
end if
Next
End Sub
I didn't put it in a procedure because I don't want to create the impression
I bench tested it - I did not, so it may contain typos but represents an
approach. It is assumed you can fine tune it to meet your needs.


Dave Peterson said:put this line right before the offending line:
msgbox "***" & cell.offset(0,1).value & "***"
Do you see what you expected between the ***'s?
I think you were correct with your assumption on worksheet names but
although am sure about the one I tried, I also did get a "subscript out of
range" error for the line:
Set sh = bk2.Worksheets(cell.Offset(0, 1).Value)
J.
workbook orMyrna Larson said:This means that you have used an incorrect name for either the
theworksheet.
Hi Dave,
Yes I do see what I expect between the ***'s.
But when I OK pass the msgbox I receive the same old error.
Hope we can solve this puzzle
Thanks
Dave Peterson said:put this line right before the offending line:
msgbox "***" & cell.offset(0,1).value & "***"
Do you see what you expected between the ***'s?
Dave Peterson said:And you're sure that name matches a worksheet name in wb2?
Maybe leading/trailing/extra spaces????
Hi Dave,
Yes it looks like the name matches the worksheet name. Would it be a good
idea if I email you the two files and see if you can work it out?. If so,
please let me know which email add. I should use...
Sincerely
J.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.