RAYLWARD102
Well-known Member
- Joined
- May 27, 2010
- Messages
- 529
I have an if statement that is used to switch the column that the data is being posted in. I want it to switch every line from g to i columns
each time it does a line.
I'm not sure; but for some reason, it does the first line to G and all of the rest after to I. I never gets set back to g. Any idea's why?
each time it does a line.
I'm not sure; but for some reason, it does the first line to G and all of the rest after to I. I never gets set back to g. Any idea's why?
Code:
Sub SCpgCREATE()
Set config = Worksheets("config") 'parameter sheet
Set ImPP = Worksheets("IMPORTED") 'import sheet
Set scPG = Worksheets("SCANpage") 'special sheet print offs
Dim iUPcol As String
iUPcol = config.Range("c16").Value
Dim iITEcol As String
iITEcol = config.Range("c17").Value
Dim iNMcol As String
iNMcol = config.Range("c18").Value
Dim iPKGcol As String
iPKGcol = config.Range("c19").Value
Dim iCScol As String
iCScol = config.Range("c20").Value
Dim iMakcol As String
iMakcol = config.Range("c21").Value
Dim cntr As Long
cntr = 1
Dim SCupCOL As String
SCupCOL = "G"
iRow2 = ImPP.Cells(Rows.Count, config.Range("c16").Value).End(xlUp).Row 'bottom col in import sheet
For Each cell In ImPP.Range(iUPcol & "1:" & iUPcol & iRow2).Cells
scPG.Range("a" & cntr).Value = ImPP.Range(iMakcol & cell.Row).Value
scPG.Range("b" & cntr).Value = ImPP.Range(iNMcol & cell.Row).Value
scPG.Range("c" & cntr).Value = ImPP.Range(iPKGcol & cell.Row).Value
scPG.Range("d" & cntr).Value = ImPP.Range(iCScol & cell.Row).Value
scPG.Range([COLOR=Red]SCupCOL[/COLOR] & cntr).Value = ImPP.Range(iUPcol & cell.Row).Value
[COLOR=Red] If SCupCOL = "G" Then
SCupCOL = "I"
Else:
sUPcol = "G"
End If[/COLOR]
cntr = cntr + 1
Next cell
End Sub