Solved Access VBA To Concatenate Excel Cells (1 Viewer)

jo15765

Registered User.
Local time
Yesterday, 21:13
Joined
Jun 24, 2011
Messages
130
Change
Code:
lColumn = ws.range("A" & ws.columns.count).end(-4159).column
to
Code:
lColumn = ws.range("XFD1").end(-4159).column

That seems to be giving valid values now...
last row = 1728
lColumn = 7
 

Isaac

Lifelong Learner
Local time
Yesterday, 21:13
Joined
Mar 14, 2017
Messages
8,826
Yay! Are there any errors?
 

Isaac

Lifelong Learner
Local time
Yesterday, 21:13
Joined
Mar 14, 2017
Messages
8,826
Glad to help and best of luck w/your project.
 

Isaac

Lifelong Learner
Local time
Yesterday, 21:13
Joined
Mar 14, 2017
Messages
8,826
Today in my own work I was reminded of a particular thing that can happen when using .End to determine that "last" row, or column, of data. There are scenarios whereby that method will take you to the edge of a previously used range which no longer has data (such as a Table that extends downward, empty, past the real filled rows of data). In that case the .End will take you to an empty cell actually, and ANOTHER .End is required to get all the way "up" (or "left"). Due to this, it's probably safer to use a method like this:

Code:
lastrow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
If Len(Cells(lastrow, 1).Value) = 0 Then
    'do it again, this time start from lastrow
    lastrow = ws.Range("A" & lastrow).End(xlUp).Row
End If

... Just thought I ought to come back and make the adjustment to my recommendation.
 

Users who are viewing this thread

Top Bottom