ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Move to the cell to the right (https://www.excelbanter.com/excel-programming/359165-move-cell-right.html)

macro_guy34345[_2_]

Move to the cell to the right
 
I am having a lot of trouble with this section of my code. My loop inserts
names on to a grid, but after the row height gets to 350, I want it to start
putting the names in the cell immediatly to the right.
This is what I have right now:

'If the current employee has both the current Results
'and Capability value then add them to that cell in the
grid
If saEmployee(2, lRecordNum) = vResults(lResCounter) _
And saEmployee(3, lRecordNum) = vCapability(lCapCounter)
Then

'Determine which cell in the grid the employee
belongs to
Set rngCell = rngGrid.Cells(1 +
lResCounter, 1 + lCapCounter)
With rngCell
If .RowHeight 350 Then
.Offset(0, 1) = .Value & Chr(10) &
saEmployee(1, lRecordNum)
Else
.Value = .Value & Chr(10) & saEmployee(1,
lRecordNum)
End If
End With
End If


Once column "A" fills up, the macro is supposed to start pasting the
remaining names in Column "B".

However, it is appending the entire contents of the original cell in column
A, into Column B, and then only the current name in the array.

sebastienm

Move to the cell to the right
 
Hi,
Replace the first 2 rows of the IF by
If .RowHeight 350 Then
.Offset(0, 1) = .Offset(0,1).Value & Chr(10) & saEmployee(1,
lRecordNum)
-- added Offset on the right side of the '='
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"macro_guy34345" wrote:

I am having a lot of trouble with this section of my code. My loop inserts
names on to a grid, but after the row height gets to 350, I want it to start
putting the names in the cell immediatly to the right.
This is what I have right now:

'If the current employee has both the current Results
'and Capability value then add them to that cell in the
grid
If saEmployee(2, lRecordNum) = vResults(lResCounter) _
And saEmployee(3, lRecordNum) = vCapability(lCapCounter)
Then

'Determine which cell in the grid the employee
belongs to
Set rngCell = rngGrid.Cells(1 +
lResCounter, 1 + lCapCounter)
With rngCell
If .RowHeight 350 Then
.Offset(0, 1) = .Value & Chr(10) &
saEmployee(1, lRecordNum)
Else
.Value = .Value & Chr(10) & saEmployee(1,
lRecordNum)
End If
End With
End If


Once column "A" fills up, the macro is supposed to start pasting the
remaining names in Column "B".

However, it is appending the entire contents of the original cell in column
A, into Column B, and then only the current name in the array.



All times are GMT +1. The time now is 05:35 PM.

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