1

I'm a beginner in using vba code and I need a statement function to make it move to a new columns with a new starting cell output when the row offset of the first columns=1048567 to continue the processing the vba code

If sq(lUser_1, 2) & "" <> sqq(lUser_2) Then

    'we found a new combination, output to screen
    Range(sStartingCellOutput).Offset(lRowOffset).Resize(, 3).Value = Array(sq(lUser_1, 2), sqq(lUser_2), rTopic.Value)

    'increment the counter
    lRowOffset = lRowOffset + 1

End If
1
  • Question is not clear. Commented Aug 15, 2015 at 10:26

1 Answer 1

2

You need to introduce another variable to take care of the column offset.

dim lColOffset as long
lColOffset = 0
If sq(lUser_1, 2) & "" <> sqq(lUser_2) Then

    'we found a new combination, output to screen
    Range(sStartingCellOutput).Offset(lRowOffset, lColOffset).Resize(1, 3).Value = _
      Array(sq(lUser_1, 2), sqq(lUser_2), rTopic.Value)

    'increment the counter
    lRowOffset = lRowOffset + 1
    if lRowOffset >= Rows.Count then
        lRowOffset = 0
        lColOffset = lColOffset + 4
    end if

End If

I've staggered the column offset by 4. You are putting three values into the rows so this will leave a blank column. Adjust that stagger is you wish.

Sign up to request clarification or add additional context in comments.

2 Comments

correct answer to an unclear question: +1 @FifoHsn - please accept the answer to close the question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.