Public Sub DisplayData(strArray() As String)
Dim intPerson As Integer
For intPerson = 1 To mintNumPeople
Cells(2, 1).Value = strArray(1)
Cells(2, 2).Value = strArray(3)
Cells(2, 3).Value = strArray(2)
Cells(2, 4).Value = strArray(5)
Cells(2, 5).Value = strArray(4)
Cells(2, 6).Value = strArray(6)
Next intPerson
Cells(intPerson + 1, 1).Value = strArray(intPerson * mintDataPerPerson)

I'm trying to make it so that the loop continues and assigns the correct string to each box. The strings go from 0-98, but every 7th number starting with 0 should not be included. We are basically filling a chart full of information from each person.

Cells(intPerson + 1, 1).Value = strArray(intPerson * mintDataPerPerson)

I know the error is in the line above, but I am unsure how to correct it. I have tried many different things and can't get it. I am very new to VBA and only know basic stuff. This is about as advanced as I have gotten.

Public Sub DisplayData(strArray() As String)
Dim intFriend As Integer
For intFriend = 1 To mintNumFriends
Cells(2, 1).Value = strArray(1)
Cells(2, 2).Value = strArray(3)
Cells(2, 3).Value = strArray(2)
Cells(2, 4).Value = strArray(5)
Cells(2, 5).Value = strArray(4)
Cells(2, 6).Value = strArray(6)

Cells(intFriend + 1, 1).Value = strArray(1 + (intFriend * mintDataPerFriend))

If intFriend < 3 Then
Cells(intFriend + 1, 1).Value = strArray(1 + mintDataPerFriend)
Else
Cells(intFriend + 1, 1).Value = strArray(1 + (intFriend * mintDataPerFriend))
End If

Cells(intFriend + 1, 2).Value = strArray(3 + (intFriend * mintDataPerFriend))

If intFriend < 3 Then
Cells(intFriend + 1, 2).Value = strArray(3 + mintDataPerFriend)
Else
Cells(intFriend + 1, 2).Value = strArray(3 + (intFriend * mintDataPerFriend))
End If

Cells(intFriend + 1, 3).Value = strArray(2 + (intFriend * mintDataPerFriend))

If intFriend < 3 Then
Cells(intFriend + 1, 3).Value = strArray(2 + mintDataPerFriend)
Else
Cells(intFriend + 1, 3).Value = strArray(2 + (intFriend * mintDataPerFriend))
End If

Cells(intFriend + 1, 4).Value = strArray(5 + (intFriend * mintDataPerFriend))

If intFriend < 3 Then
Cells(intFriend + 1, 4).Value = strArray(5 + mintDataPerFriend)
Else
Cells(intFriend + 1, 4).Value = strArray(5 + (intFriend * mintDataPerFriend))
End If

Cells(intFriend + 1, 5).Value = strArray(4 + (intFriend * mintDataPerFriend))

If intFriend < 3 Then
Cells(intFriend + 1, 5).Value = strArray(4 + mintDataPerFriend)
Else
Cells(intFriend + 1, 5).Value = strArray(4 + (intFriend * mintDataPerFriend))
End If

Cells(intFriend + 1, 6).Value = strArray(6 + (intFriend * mintDataPerFriend))

If intFriend < 3 Then
Cells(intFriend + 1, 6).Value = strArray(6 + mintDataPerFriend)
Else
Cells(intFriend + 1, 6).Value = strArray(6 + (intFriend * mintDataPerFriend))
End If

Next intFriend

I've managed to get what I wanted but for some reason I can't get it to stop skipping intFriend = 3, any advice?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.