ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I do this? (https://www.excelbanter.com/excel-programming/328863-how-do-i-do.html)

Greg B[_5_]

How do I do this?
 
I am currently writing a spreadsheet where i put numbers across a page and
they are in columns 1 to 14.

I want a code to look up the last used cell on column "g4" for example

and give me the corresponding cell on g1

I am not sure on how to word this. Hope this is clear enough

Thanks in advance

Greg



WindsurferLA

How do I do this?
 
A better description of what you want would be helpful. You speak of
column "G4", but the columns are identified by one or two letter over
the range of A through IV.

What do you want to look up in the "last cell?" Do you want its value?

I suspect you want to find the first column where there is data in the
4th row, and to then retrieve the data from the cell in the first row of
that column. Is my guess correct?

If you want to find the last column in any row that is non zero, the
general procedure is to go all the way to the right (make row IV the
active cell) and then come back to the first entry using the equivalent
of control-left.


Greg B wrote:
I am currently writing a spreadsheet where i put numbers across a page and
they are in columns 1 to 14.

I want a code to look up the last used cell on column "g4" for example

and give me the corresponding cell on g1

I am not sure on how to word this. Hope this is clear enough

Thanks in advance

Greg




Patrick Molloy[_2_]

How do I do this?
 
Option Explicit
Sub AllColumns()
Dim col As Long
For col = 2 To 14
OneColumn col
Next
End Sub
Sub OneColumn(col As Long)
Dim rw As Long

rw = Cells(65000, col).End(xlUp).Offset(1, 0).Row
Cells(rw, col).Value = Cells(rw, 1).Value

End Sub

HTH
Patrick Molloy
Microsoft Excel MVP

"Greg B" wrote:

I am currently writing a spreadsheet where i put numbers across a page and
they are in columns 1 to 14.

I want a code to look up the last used cell on column "g4" for example

and give me the corresponding cell on g1

I am not sure on how to word this. Hope this is clear enough

Thanks in advance

Greg





All times are GMT +1. The time now is 01:09 AM.

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