Found last used column from Row 2, need value in row 1

Opal

New Member
Joined
May 1, 2005
Messages
17
Hello all,

I have been trying all afternoon to get something working and I can't figure out how to do this....

I am using the following to find the last used column in row 2 on my work sheet:

LastColumn = Sheets("Summary").Cells(2, Sheets("Summary").Columns.Count).End(xlToLeft).Column

I want to find the value in row 1 of this column and compare it to a value in another worksheet. I can't quite figure out how to accomplish this. I have been "Playing around" with the following:

Rng = Sheets("Summary").Cells(1, LastColumn - 1).Value

If Sheets("qryAccessExport").Range("A2") = Rng.Offset(-1, 0).Value Then
MsgBox "You have already copied this data over.", vbInformation + vbOKOnly
Exit Sub
End If

I don't know if I am on the right track or not. I am trying to automate a spreadsheet for bring in data on a monthly basis from an Access database.

Any help or pointing me in the right direction would be appreciated. Thank you!
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,692
The value in row 1 of "this column", assuming that's LastColumn is: Cells(1,LastColumn).Value
 

Watch MrExcel Video

Forum statistics

Threads
1,089,947
Messages
5,411,462
Members
403,372
Latest member
andrepi

This Week's Hot Topics

Top