![]() |
If cell equals anything then
I am trying to write a macro that pulls date from one sheet and puts
it into another sheet which I am going to e-mail. I only want the cells that have information in them. Can someone help me? This is what I am trying For cnt = 7 To lrow2 If wsmiss102.Range("b" & cnt) = xlValue Then _ wsmiss102.Rows(cnt).Copy ThisWorkbook.Sheets("Misses").Rows(x).PasteSpecial x = x + 1 End If Next I am getting nothing copied over. But this is what I have in the third row. 6021427993 BLAYLOCK 1-20 Bad X-Record Length Thu Sep 06 04:00:35 I know it has something to do with xlvalue but I don't know what to replace it with. |
If cell equals anything then
Try this:
For cnt = 7 To lrow2 If wsmiss102.Range("b" & cnt) < "" Then _ wsmiss102.Rows(cnt).Copy ThisWorkbook.Sheets("Misses").Rows(x).PasteSpecial Paste:=xlValues cnt = cnt + 1 End If "bpotter" wrote: I am trying to write a macro that pulls date from one sheet and puts it into another sheet which I am going to e-mail. I only want the cells that have information in them. Can someone help me? This is what I am trying For cnt = 7 To lrow2 If wsmiss102.Range("b" & cnt) = xlValue Then _ wsmiss102.Rows(cnt).Copy ThisWorkbook.Sheets("Misses").Rows(x).PasteSpecial x = x + 1 End If Next I am getting nothing copied over. But this is what I have in the third row. 6021427993 BLAYLOCK 1-20 Bad X-Record Length Thu Sep 06 04:00:35 I know it has something to do with xlvalue but I don't know what to replace it with. |
If cell equals anything then
No that doesn't work. It collects all of the empty rows not the rows
that have values. |
If cell equals anything then
This line
If wsmiss102.Range("b" & cnt) < "" Then _ should prevent any empty lines from being copied. Is says if the specified range is not equal to null then ... do something. So the only cells it will acknowledge are those with data in them. "bpotter" wrote: No that doesn't work. It collects all of the empty rows not the rows that have values. |
If cell equals anything then
See if this idea helps
Sub copyvalues() x = 1 For Each c In Range("a2:a22") If Len(Trim(c)) 0 Then Rows(c.Row).Copy Sheets("sheet11").Cells(x, 1) x = x + 1 End If Next c End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "bpotter" wrote in message ps.com... I am trying to write a macro that pulls date from one sheet and puts it into another sheet which I am going to e-mail. I only want the cells that have information in them. Can someone help me? This is what I am trying For cnt = 7 To lrow2 If wsmiss102.Range("b" & cnt) = xlValue Then _ wsmiss102.Rows(cnt).Copy ThisWorkbook.Sheets("Misses").Rows(x).PasteSpecial x = x + 1 End If Next I am getting nothing copied over. But this is what I have in the third row. 6021427993 BLAYLOCK 1-20 Bad X-Record Length Thu Sep 06 04:00:35 I know it has something to do with xlvalue but I don't know what to replace it with. |
All times are GMT +1. The time now is 10:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com