VBA to copy/paste from IF formula without creating an empty string

MarkR3003

New Member
Joined
Aug 11, 2019
Messages
25
I am trying to create a macro that will copy the rows in a 24 row table that contain data (but not the rows with only an IF formula giving "" as the FALSE value) and copy them to another workbook in a table after looking for the next blank row. On running the macro for a second time, it considers the blank rows in the receiving table to have an empty string, so pastes the values below the empty / blank rows rather than in the next row below the actual cell values (numeric, general and date)

Grateful if you could check my VBA and amend to ignore the rows with the empty strings ("")

Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long


'Set variables for copy and destination sheets
Set wsCopy = Workbooks("Book1.xlsm").Worksheets("Database Transfer")
Set wsDest = Workbooks("Book2.xlsx").Worksheets("2021")


'1. Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row


'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row


'3. Copy & Paste Data
wsCopy.Range("A2:V" & lCopyLastRow).Copy
wsDest.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlValues
Selection.Value = Selection.Value
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I am having the same problem but I am getting a property mismatch.

Sheets("Sheet1").Select
Range("G:G").Find("*", , xlValues, , xlByRows, xlPrevious, , , False).Row
Selection.Copy

I am trying to find the last cell without a "" being returned, and selecting all rows above it except for a header.
 
Upvote 0
Please start a new thread for this question. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,830
Messages
6,181,227
Members
453,025
Latest member
Hannah_Pham93

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top