Provide value of the last populated cell in row

AlgerianHippo

New Member
Joined
Jun 4, 2019
Messages
2
Is there a formula or way that you would look at all the cells to the left of it, and return the rightmost cell?

For example,

ABCDE----------FORMULA (Returns E)
ABC-------------FORMULA (Returns C)
ABCDEFG-------FORMULA (Returns G)
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Is there a formula or way that you would look at all the cells to the left of it, and return the rightmost cell?

For example,

ABCDE----------FORMULA (Returns E)
ABC-------------FORMULA (Returns C)
ABCDEFG-------FORMULA (Returns G)


Code:
Sub Count_To_Last_Column_In_Row()
Dim I as long,H as long
'Variable "I" is the row number that you want to count
'You can loop through the number of rows and set I to the current row with a "for loop"

'Will not work if there are empty cells in-between the number of cells you want to count

H=Activesheet.Range("A"&I).End(xlToright).column


End Sub

All that would be left for you to do is to write that value to the cell you want or use a msgbox
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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