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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,659
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

JarmoVee

New Member
Joined
May 27, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Thank you very much Fluff! It works and you save my day :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,659
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,141,858
Messages
5,709,035
Members
421,606
Latest member
Faisel135

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
Top