Macro for Copying/combing data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I need a macro that will copy/combine data for several workbooks from sheets *.Newvehicles (each work sheet will have a different worksheet ending in for eg newton.newvehicles columnns O:U

I the current workbook "Consolidated New Vehicles" Sheet1, the data must be copied/consolidated into this new workbook, except the data containing the words Total for eg Total Units, Total Value

See sample data below-In this example the data must be copied up to line 20. Row 1 must be copied in the first worksheet and thereafter from row row, excluding the totals

Your assistance in this regard will me most appreciated

Howard
Newton.newvehicles.xls
OPQRSTU
1969FOCUS2.5ST5DRMAN11,25026711,517newton190
20682FIESTA1.6DAMBIENTE5DR11,36028111,641newton240
21
22
23TotalUnits19
24
25TotalValue213,8605,045218,905
Newton.newvehicles
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
normally the macro given below should work. But I thing your rows 21 and 22
column O and to right are NOT blanks. If keep the cursor at O19 and hit end-down arrow it should go to O20 but it goes to O23. there is some entry or formula in rows 21 and 22.

clarify this point

preliminary macro (not teted ) is
with the proviso that rows 21 and 22 are blank the copying is done row 2 in the "consolidateed ..." file row 1 is blank for entering column headings.

Code:
Sub test()
Dim wbdest As Workbook
Dim rng As Range
Set wbdest = Workbooks("Consolidated New Vehicles.xls")
With ThisWorkbook.Worksheets("Newton.newvehicles")
Set rng = Range(.Range("O19"), .Range("O19").End(xlToRight).End(xlDown))
rng.Copy
With wbdest.Worksheets("sheet1")
.Cells(Rows.Count, "a").End(xlUp).Offset(1#).PasteSpecial
End With
End With

End Sub
 
Upvote 0
Hi Venkat

thanks for the help. Macro is not working properly. Have emailed you my file. Once working properly, please post soloution on MrExcel.com

Regards

Howard
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,426
Members
448,961
Latest member
nzskater

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