Macro Help

lgirardin

New Member
Joined
Jan 25, 2022
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
How does one go about writing a macro that copies multiple ranges of cells, but only copies the ones with data, and pastes them into a different workbook/worksheet? This is what I have so far, but I don't know how to copy only cells with data. Any help would be appreciated!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Sub Transfer1()
'
' Transfer1 Macro
'

'
ActiveSheet.Range("A9:A45").Copy Destination:=Workbook.Worksheet.Range("B7:B43")
ActiveSheet.Range("A47:A76").Copy Destination:=Workbook.Worksheet.Range("B44:B73")


End Sub
 
Upvote 0
Sub Transfer1()
'
' Transfer1 Macro

'
ActiveSheet.Range("A9:A45").Copy Destination:=Workbook.Worksheet.Range("B7:B43")
ActiveSheet.Range("A47:A76").Copy Destination:=Workbook.Worksheet.Range("B44:B73")

ActiveSheet.Range("C9:C45").Copy Destination:=Workbook.Worksheet.Range("C7:C43")
ActiveSheet.Range("C47:C76").Copy Destination:=Workbook.Worksheet.Range("C44:C73")
ActiveSheet.Range("E9:E45").Copy Destination:=Workbook.Worksheet.Range("F9:F43")
ActiveSheet.Range("E47:E76").Copy Destination:=Workbook.Worksheet.Range("F44:F73")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,179
Members
448,871
Latest member
hengshankouniuniu

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