Reading a value into a variable

Titian

Well-known Member
Joined
Dec 17, 2004
Messages
567
Using code posted by Peter_SSs yesterday I am attempting to get into the variable TOTPT the total value generated by a pivot table.

The code I have so far locates the cell (column and row) containing the value, however I cannot fathom how to get the value into the variable.

My code is: totpt = Range("LastColumn & Chr(10) & pivotlastrow").Select

LastColumn ="AR", Pivotlastrow =730

Please help
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi Titian

In this example, you simply need to replace the Select with Value:

Code:
totpt = Range("LastColumn & Chr(10) & pivotlastrow").Value

Best regards

Richard
 
Upvote 0
Thanks for your suggestion Richard.

I am getting an error at that line, "Method 'Range' of object '_Global' failed" and the result of testing TOTPT = Empty.

Any further suggestions?

Thanks again.
 
Upvote 0
Sorry, should have reviewed what I typed a bit more carefully:

Code:
totpt = Range(LastColumn &  pivotlastrow).Value

Hopefully, this should work!

Richard
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

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