I'm relatively new in Excel VBA and what i'm doing is a loader for one of our ERPs. So my problem is this...I have an excel worksheet, let's call it the origin and another one, let's call it dummy.
What i want to do is for the macro to check if a certain cell (af18) in origin range falls into criteria. If its true, then copy a A18 from origin sheet to dummy sheet. Then insert "{tab} on the next column. then if AF19 (the next cell) falls into the criteria, copy the a19 to dummy's next blank column then again insert {tab}.
The current code produces this: 1,2,3...\{tab}
But I want it to be like this: 1,\{tab},2,\{tab}...
Sub CreateLoaderBeta()
Dim origin As Worksheet
Dim destination As Worksheet
Dim desrow As Long
Dim descol As Long
Dim descolstart As Long
Dim origrow As Long
Dim origcol As Long
Dim rang As Range
Dim C As Range
Dim qual As Integer
Set origin = Sheets("1")
Set destination = Sheets("dummy")
desrow = 3
descol = 1
origrow = 18
origcol = 32
Set rng = Sheets("1").Range("AF18:af47")
total = WorksheetFunction.SUM(Worksheets("1").Range("AF18:AF47"))
descolstart = destination.cells(desrow, Columns.Count).End(xlToLeft).column
If total > 0 Then
'Dim headcol As Integer
'headcol = 1
'origin.cells(3, headcol).Copy
'destination.cells(1, descolstart).PasteSpecial Paste:=xlPasteValues
For Each C In rng
If C = 14 Then
origin.cells(origrow, 1).Copy
destination.cells(1, descolstart).PasteSpecial Paste:=xlPasteValues
destination.cells(1, descolstart + 1).Value = "\{TAB}"
descolstart = descolstart + 1
origrow = origrow + 1
End If
Next C
destination.Columns("A:U").insert Shift:=xlToRight
Call headers
Else 'Donothing
End If
MsgBox total
End Sub**
