ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   one last macro question (https://www.excelbanter.com/excel-programming/324720-one-last-macro-question.html)

Michael A

one last macro question
 
ok, so this macro is working great..

Sub CopyToSheetz()

Dim rng As Range
Dim oCell As Range

Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
For Each oCell In rng
oCell.EntireRow.Copy _
Destination:=Sheets(oCell.Value).Range("A65536").E nd(xlUp).Offset(1,
0)
Next oCell


End Sub
-----

except, i have this formula in my B column

=IF(A4="","",IF(ISERROR(VLOOKUP(A4,'Names
List'!$A$5:$E$5000,2,FALSE)),"NA",VLOOKUP(A4,'Name s
List'!$A$5:$E$5000,2,FALSE)))

so when the macro gets to the lines that have the "" in it, i get a syntax
error. Can someone help me get around this? I dont need these lines copied, I
just wanetd to get rid of the #N/A if A is blank.
Any help would be great..

Thanks!

gocush[_29_]

one last macro question
 
For Each oCell In rng
If oCell.Offset(0-1)<"" Then
oCell.EntireRow.Copy _
Destination:=Sheets(oCell.Value).Range("A65536").E nd(xlUp).Offset(1,
0)
end if
Next oCell




"Michael A" wrote:

ok, so this macro is working great..

Sub CopyToSheetz()

Dim rng As Range
Dim oCell As Range

Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
For Each oCell In rng
oCell.EntireRow.Copy _
Destination:=Sheets(oCell.Value).Range("A65536").E nd(xlUp).Offset(1,
0)
Next oCell


End Sub
-----

except, i have this formula in my B column

=IF(A4="","",IF(ISERROR(VLOOKUP(A4,'Names
List'!$A$5:$E$5000,2,FALSE)),"NA",VLOOKUP(A4,'Name s
List'!$A$5:$E$5000,2,FALSE)))

so when the macro gets to the lines that have the "" in it, i get a syntax
error. Can someone help me get around this? I dont need these lines copied, I
just wanetd to get rid of the #N/A if A is blank.
Any help would be great..

Thanks!


GaryDK

one last macro question
 
If you're just concerned with blank cells, try wrapping your copy
statement in -

If Len(ActiveCell.Value) 0 Then
End If

Gary


Tom Ogilvy

one last macro question
 
Sub Macro1()
Dim rng as Range
Dim rng1 as Range
With Activesheet
set rng = .Range(.Range("B4"), _
.Range("B65536").End(xlup))
End With
for each cell in rng
set rng1 = Nothing
On error resume next
set rng1 = worksheets(cell.value). _
cells(rows.count,1).end(xlup)(2)
On error goto o
if rng1 is nothing then
cell.EntireRow.copy Destination:= _
rng1
Next
Application.CutCopyMode = False
End Sub

--
Regards,
Tom Ogilvy


"Michael A" wrote in message
...
ok, so this macro is working great..

Sub CopyToSheetz()

Dim rng As Range
Dim oCell As Range

Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
For Each oCell In rng
oCell.EntireRow.Copy _

Destination:=Sheets(oCell.Value).Range("A65536").E nd(xlUp).Offset(1,
0)
Next oCell


End Sub
-----

except, i have this formula in my B column

=IF(A4="","",IF(ISERROR(VLOOKUP(A4,'Names
List'!$A$5:$E$5000,2,FALSE)),"NA",VLOOKUP(A4,'Name s
List'!$A$5:$E$5000,2,FALSE)))

so when the macro gets to the lines that have the "" in it, i get a syntax
error. Can someone help me get around this? I dont need these lines

copied, I
just wanetd to get rid of the #N/A if A is blank.
Any help would be great..

Thanks!





All times are GMT +1. The time now is 09:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com