How do I assign the following into a variable?

Oberon70

Board Regular
Joined
Jan 21, 2022
Messages
160
Office Version
  1. 365
Platform
  1. Windows
I am trying to figure out how to code VBA to consolidate a range on one of my sheets.

The sheet would have the following on it:

1643083717062.png


and once consolidated it would look like (not consolidating the 7101)

1643083783808.png


The size of the above data can be different from each report, but it is always A1:D and then lRow is my variable that the number of rows are assigned to.
I came across the website with information on consolidating.

Consolidated Data Link

and thought I ad to convert my range address to R1C1 and found the below:

Msgbox Application.ConvertFormula(Formula:="A2:" & "D" & lRow, FromReferenceStyle:=xlA1, ToReferenceStyle:=xlR1C1)

1643083464765.png


However, I don't know how I take this part Application.ConvertFormula(Formula:="A2:" & "D" & lRow, FromReferenceStyle:=xlA1, ToReferenceStyle:=xlR1C1) and assign it to a variable

or if there is a better way to accomplish the above?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
or if there is a better way to accomplish the above
Sum columns in a dynamic named range - no code?
I forget if the dynamic range has to be at the sheet or workbook level, but I might still have a copy of a file that uses a dynamic range, or you could google it for the details.
 
Upvote 0

Forum statistics

Threads
1,222,902
Messages
6,168,938
Members
452,227
Latest member
sam1121

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