Simple macros to re-arrange column into upload format
Excel macros to re-arrange column from text file into rows format. Please watch the video below.
1. Create 2 Macros name in you excel.
1. Create 2 Macros name in you excel.
2. All Macros code have to paste in Module1.
3. Copy Macros's code below.
Sub Remove()
' Delete title line
Rows("1:5").Select
Selection.Delete Shift:=xlUp
'
For i = 1 To 9000
Range("A" & i).Select
If Left(ActiveCell.Value, 1) = "-" Then
Rows(i & ":" & i).Select
Selection.Delete Shift:=xlUp
End If
Next
' Delete column B and D
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
' Paste title in Sheet2
Sheets("Sheet1").Select
Range("A1:A9").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets("Sheet1").Select
Range("C1:C9").Select
Selection.Copy
Sheets("Sheet2").Select
Range("J1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets("Sheet1").Select
Range("E1").Select
Selection.Copy
Sheets("Sheet2").Select
Range("S1").Select
ActiveSheet.Paste
End Sub
Sub addnew()
Dim lines As Long
Dim records(18) As String
lines = 1
For i = 1 To 8000
Sheets("Sheet1").Select
Range("A" & i).Select
If ActiveCell.Value = "Supplier" Then
For a = 0 To 8 ' add into record.
irow = i + a
Range("B" & irow).Select
records(a) = ActiveCell.Value
Debug.Print records(a) & " Array (" & a & ")"
Range("D" & irow).Select
records(a + 9) = ActiveCell.Value
Debug.Print records(a + 9) & " Array (" & a + 9 & ")"
If a = 0 Then
Range("F" & irow).Select
records(18) = ActiveCell.Value
Debug.Print records(18) & " Array (18) "
End If
Next
Debug.Print "---add Records----"
Debug.Print ""
Sheets("sheet2").Select
lines = lines + 1
For w = 0 To 18
Range(Chr(65 + w) & lines).Select
ActiveCell.Value = records(w)
Next
For r = 0 To 18
records(r) = ""
Next
End If
Next
End Sub
Comments
Post a Comment