Multiple ranges?

samilynn

Board Regular
Joined
Jun 24, 2003
Messages
166
Office Version
  1. 2016
Platform
  1. Windows
I am using this code within a macro, to autofill until the end of the range.
It works, but I can't get it to run if I want to use it on multiple columns (i.e: Columns M, R, and T).
Help, please?
thank you!
Samantha


Dim rngData As Range, rngFormula As Range
With ActiveSheet
Set rngData = .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
Set rngFormula = .Range("M2")
rngFormula.AutoFill _
Destination:=.Range(rngFormula, _
.Cells(rngData.Rows(rngData.Rows.Count).Row, rngFormula.Column))
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
try
Code:
With ActiveSheet
   .Range("M2").AutoFill .Range("M2:M" & .Range("A" & Rows.Count).End(xlUp).Row)
End With
 
Upvote 0
Code

Code:
Sub Macro1()
With ActiveSheet
LR = .Range("A" & Rows.Count).End(xlUp).Row
   .Range("M2:M" & LR & ",R2:R" & LR & ",T2:T" & LR).Value = .Range("M2").Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

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