ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Far Right data in a Selected Row (https://www.excelbanter.com/excel-programming/360230-select-far-right-data-selected-row.html)

tmony

Select Far Right data in a Selected Row
 

I am very new to Macro's but am trying to modify an existing one inside
a spreadsheet I have to update.

What I have to do is select a range of cells in one row, i.e. D21:DX21.
I want to take the data from the farthest right cell in that range that
contains data, and place that value in B21.

Hopefully this is a simple request!!

Thanks in advance for any help I can get!


--
tmony
------------------------------------------------------------------------
tmony's Profile: http://www.excelforum.com/member.php...o&userid=28966
View this thread: http://www.excelforum.com/showthread...hreadid=537773


Tom Ogilvy

Select Far Right data in a Selected Row
 
I assume you mean with code and not formulas?

Dim rng as Range
set rng = Range("DX21")
if isempty(rng) then
set rng = rng.End(xltoLeft)
end if
if rng.Column = 4 then
Range("B21").Value = rng.Value
else
Msgbox "Range of interest is empty"
End if

--
Regards,
Tom Ogilvy




"tmony" wrote:


I am very new to Macro's but am trying to modify an existing one inside
a spreadsheet I have to update.

What I have to do is select a range of cells in one row, i.e. D21:DX21.
I want to take the data from the farthest right cell in that range that
contains data, and place that value in B21.

Hopefully this is a simple request!!

Thanks in advance for any help I can get!


--
tmony
------------------------------------------------------------------------
tmony's Profile: http://www.excelforum.com/member.php...o&userid=28966
View this thread: http://www.excelforum.com/showthread...hreadid=537773




All times are GMT +1. The time now is 11:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com