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!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
The value in row 1 of "this column", assuming that's LastColumn is: Cells(1,LastColumn).Value
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

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