Simplify macro [VBA]

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to simplify my macro but no luck so far.

Would it be possible to fit this code (see below) - somehow - into one line?

VBA Code:
Range("AL2:AL" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AM2:AM" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AN2:AN" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AO2:AO" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AP2:AP" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AQ2:AQ" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AR2:AR" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AS2:AS" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AT2:AT" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AU2:AU" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AV2:AV" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AW2:AW" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"
Range("AX2:AX" & LastRowColumnA).Formula = "=GETCOMMENTS(RC[-25])"

Thank you.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
How about
VBA Code:
Range("AL2:AX" & LastRowColumnA).FormulaR1C1 = "=GETCOMMENTS(RC[-25])"
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,834
Members
449,051
Latest member
excelquestion515

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