VBA problems with formulas

JarmoVee

New Member
Joined
May 27, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello,

First of all sorry my bad english...

From The Workbook "Parts List.xlsm" can be found in the Worksheet "Parts" and there is a parts list defined in the A2: H20 area, which should make the VBA move to another Workbook (Parts.xlsx) one below the other.
The code I made now moves the cells that are "empty" and the next copy moves after the first move to the cell A39 and the next to A59 etc .....
What is wrong with that or does this also take empty cells where are formulas only in the range A2: H20?

How can I fix this?

Thank you in advance!


VBA Code:
Sub Parts_list()

Dim wbGood As Workbook
Dim wsCopy As Worksheet, wsDest As Worksheet
Dim lCopyLastRow As Long, lDestLastRow As Long

Set wbGood = Workbooks("Partslist.xlsm")
Set wbGood = Workbooks("Parts.xlsx")

Set wsCopy = Workbooks("Partslist.xlsm").Worksheets("Parts")
Set wsDest = Workbooks("Parts.xlsx").Worksheets("Taul1")

lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row

lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row

wsCopy.Range("A2:H" & lCopyLastRow).Copy
wsDest.Range("A" & lDestLastRow).PasteSpecial xlValues

Application.CutCopyMode = False

End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi & welcome to MrExcel.
Doing it like that will paste a nullstring into any cells that had a formula returning "", try it like
VBA Code:
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row

lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row

wsDest.Range("A" & lDestLastRow).Resize(lCopyLastRow - 1, 8).Value = wsCopy.Range("A2:H" & lCopyLastRow).Value


End Sub
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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