Search : in
By :

Returning contents of last cell in row

Last answer on Nov 13, 2009 4:37:02 pm GMT Rebecca, on Oct 1, 2008 6:52:42 pm BST 
 Report this message to moderators

Hello,

I am trying to write a macro that returns the data contents of the last cell in a row of data. I then need to declare the cell's data as a variable.

So far, my code is this (from another online tutorial):

Public Sub LastColumnInOneRow()
'Find the last used column in Row1: row 1 in this example
Dim LastCol1 As Double
With ActiveSheet
LastCol1 = Range("IV3").End(xlToLeft).Column
End With
MsgBox LastCol1
End Sub

I only seem to be about to get hte program to return a count of the cols for me, not the actual cell data. Please help.

Thanks,

R

Configuration: Windows XP
Internet Explorer 7.0

Best answers for « Returning contents of last cell in row » in :
Excel – Comparing cell A1 to entire A column in Sheet 2 ShowExcel – Comparing cell A1 to entire A column in Sheet 2 Issue Solution Note Issue I have been trying to compare sheet1 A2 to sheet2 A2 through A500 and if it exists somewhere in sheet2's a col then copy that entire row to a new sheet....
[VBA] Detecting changes in cell Show[VBA] Detecting changes in cell The Event Change feature of a sheet will detects the change in the active cell but it gives no information about the content. The example given below will help you to find out if the cell was changed,...
EXCEL: The INTERSECTION function ShowEXCEL: The INTERSECTION function You have a table consisting of rows and columns. Want to know the value of the cell at the intersection of a particular row / column in your table Example: Your table: - starts C3 to F3 ......
Spreadsheets - Cell Selection ShowCell Selection Spreadsheets are powerful tools for working with data. However, to work with data, it is necessary to have tools to rapidly choose the required cells. Line Selection An entire line can be chosen by clicking directly on the line...
Control - control.exe Showcontrol - control.exe control.exe (control stands for Control Panel) is a Windows NT/2000/XP generic process which corresponds to the control panel. The file that corresponds to this process is normally found in the directory...
CMS (Content Management System) ShowContent Management System A "CMS" (Content Management System) is a website with certain publishing features. In particular, it has a back-end interface that lets an administrator on the site create or organise different documents. Ideally, a CMS...

2

Ivan-hoe, on Oct 1, 2008 9:01:53 pm BST
  • +1

Hello Rebecca,
to make the program return the data in the cell, use .Value
e.g. :

Dim LastCol1 as Double
Dim MyVariable

LastCol1 = Range("IV3").End(xlToLeft).Column 
MyVariable = Cells(3,LastCol1).Value
MsgBox MyVariable

ou can also write
MyVariable = Range("IV3").End(xlToLeft).Value

Ivan

Reply to Ivan-hoe

chris, on Feb 3, 2009 11:58:59 pm GMT
  • +3

I would like to take the last amount in a column and subtract it from a number and have the value displayed in a cell. What forumla can I use or macro

Reply to chris

3

 Sharkiness, on Nov 13, 2009 4:37:02 pm GMT

Do you know how I would get the value pasted into a new cell using this macro

Reply to Sharkiness