Last value in a column H using VBA

AC

Board Regular
Joined
Mar 21, 2002
Messages
153
I can use MsgBox Cells(Rows.Count, 8).End(xlUp).Value to get the last value in column H.

But now I have formulas in column H, like this =(IF(OR(F35,G35>0), OFFSET(H35,-1,0)- F35+G35,"")) and the msgbox is showing blank because it is looking at the last cell in column H. I need some code to get the last VALUE from that column. So if I have the foumulas in H4:H100 but the last value is in H25, H26:H100 are showing "", I need what in in H25
Thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I can use MsgBox Cells(Rows.Count, 8).End(xlUp).Value to get the last value in column H.

But now I have formulas in column H, like this =(IF(OR(F35,G35>0), OFFSET(H35,-1,0)- F35+G35,"")) and the msgbox is showing blank because it is looking at the last cell in column H. I need some code to get the last VALUE from that column. So if I have the foumulas in H4:H100 but the last value is in H25, H26:H100 are showing "", I need what in in H25
Thanks

You could also invoke a formula to fetch the last numeric value from the range of interest:

=LOOKUP(9.99999999999999E+307,H4:H100)
 
Upvote 0
Aladin, thanks, I know about that using a formula but wanted to use it in some code to do something if that cell was less than 2500, thought it would be easy in VBA but maybe not, I will put that formula in a cell and have my code look at it for the number.
Thanks again
 
Upvote 0
Aladin, thanks, I know about that using a formula but wanted to use it in some code to do something if that cell was less than 2500, thought it would be easy in VBA but maybe not, I will put that formula in a cell and have my code look at it for the number.
Thanks again

You are welcome. In fact, formulas and code should interact thru posted results cells or groups of cells. By the way, thanks for providing feedback.
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,314
Members
452,905
Latest member
deadwings

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