visualnewbie09
New Member
- Joined
- Jul 23, 2014
- Messages
- 16
I have a table that needs headers assigned to it. I have copied a link to view the example spreadsheets. The first sheet has the table and the second sheet has the headers. The code is designed to go to sheet 1 see what file name is being used and assign the header to the file name. Each file has two columns of data for Location 1 and Location 2, but have the same file name so it's assigns the first header, but ignores the second header. If someone could fix so it so that it assigns it by the file name and also if it's Location 1 data or Location 2 data.
https://docs.google.com/spreadsheets/d/1QDcX-smS8Wp-ryWw8NNrjiPU1vI9E-WeSYRiroztJHk/edit?usp=sharing
https://docs.google.com/spreadsheets/d/1QDcX-smS8Wp-ryWw8NNrjiPU1vI9E-WeSYRiroztJHk/edit?usp=sharing
Code:
Sub FindHeaders()
Dim iRowH, iColH, iRowD, iColD As Integer
Dim strHeader, strData, strTitle As String
iRowD = 3
iColD = 2
iRowH = 2
iColH = 1
Sheets("Sheet1").Activate
Do Until Len(Cells(iRowD, iColD).Value) < 1
strData = Cells(iRowD, iColD).Value
Sheets("Sheet 2").Activate
Do Until Len(Cells(iRowH, iColH).Value) < 1
strHeader = Cells(iRowH, iColH).Value
If strData = strHeader Then GoTo HeaderFound
iRowH = iRowH + 2
Loop
'Header Data not Found
HeaderFound:
strTitle = Cells(iRowH - 1, iColH).Value
Sheets("Sheet 1").Activate
Cells(iRowD - 2, iColD).Value = strTitle
iColD = iColD + 3
Loop
End Sub