Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have the Code implemented to the return the value like (11111 or 11112 or 11113 or 11114 or 11115). But failed always returning only ( 11114 or 11115). How to resolve it. Please help me.

VB
Private Sub CommandButton1_Click()
RowCount = ActiveWorkbook.Worksheets("Sheet1").Range("A2", Worksheets("Sheet1").Range("A2").End(xlDown)).Rows.Count
ColomCount = ActiveWorkbook.Worksheets("Sheet1").Range("A2", Worksheets("Sheet1").Range("A2").End(xlDown)).Columns.Count
For i = 2 To RowCount
For j = 1 To ColomCount
'MsgBox (RowCount)
'MsgBox (ColomCount)
'If Not Sheet1.Cells(i, j).Value = vbNullString Then
'varConctnt = Sheet1.Cells(i, j).Value & " or " & Sheet1.Cells(i + 1, j).Value
Sheet1.Cells(2, 2) = Sheet1.Cells(i, j).Value & " or " & Sheet1.Cells(i + 1, j).Value
'End If
Next j
'If varConctnt = vbNullString Then MsgBox "Empty Array": 'GoTo skip1
'Sheet1.Cells(2, 2) = varConctnt
'varConctnt = ""
'skip1:
Next i
End Sub
Posted
Comments
Maciej Los 17-Sep-14 16:51pm    
Please, be more specific and provide more details.

1 solution

Debug the program and you'll see why it happens ;)

Tip: In each step of loop the value in Sheet1.Cells(2, 2) is overwritten.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900