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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
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
 

Titian

Well-known Member
Joined
Dec 17, 2004
Messages
567
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.
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Sorry, should have reviewed what I typed a bit more carefully:

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

Hopefully, this should work!

Richard
 

Forum statistics

Threads
1,136,309
Messages
5,674,999
Members
419,541
Latest member
freddyboots

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
Top