excel macro range issue

Tonyk1051

Board Regular
Joined
Feb 1, 2021
Messages
131
Office Version
  1. 2019
Platform
  1. Windows
1659887388361.png


this a screen shot of a recorded macro to change date format with a formula. It works but when i run the macro on another workbook that has much less or more lines, its doesnt populate. what do i need to add to the code for it to adapt to any number of lines? thanks in advance
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
VBA Code:
With ActiveSheet
      .Range("H2", .Range("H" & .Rows.Count).End(xlUp)).Offset(0, 1).FormulaR1C1 = "=Text(RC[-1],""m/yy"")"
 End With

(Tip: when posting code, please try to use 'code tags' to format the code as I have done above
it makes the code easier to read.)
 
Upvote 0
Solution
VBA Code:
With ActiveSheet
      .Range("H2", .Range("H" & .Rows.Count).End(xlUp)).Offset(0, 1).FormulaR1C1 = "=Text(RC[-1],""m/yy"")"
 End With

(Tip: when posting code, please try to use 'code tags' to format the code as I have done above
it makes the code easier to read.)
noted and thanks,
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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