Hi guys here is the 2 macros I have for this issue. The first one transforms one row from into 4 different rows and the next one removes the rows that have a zero. This way seems to crude and I was wondering how would I improve it. I'm thinking arrays and ranges probably? Thanks a lot
Sub ImportIntoAccess()
Sheets("RC").Select
Range("b2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("A1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("b1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("c1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("h2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("d1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("e2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Loans"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
Range("G2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "3"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
Sheets("RC").Select
Range("b2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("b1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("c1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("f2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("d1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("G1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "4"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
Sheets("RC").Select
Range("b2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("b1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("c1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("g2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("d1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("G1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "5"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
End Sub
Sub Delete_Chg_Total_zero()
Dim r As Long
Dim LastRow As Long
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
For r = LastRow To 1 Step -1
If Cells(r, 4) = 0 Then
Rows(r).Delete
End If
Next r
End Sub
Here is the link to my spreadsheet
https://drive.google.com/file/d/11xG_cbu-HglAqX6a8XwjuolzHOmC3za7/view?usp=drivesdk
Or if this is not allowed please advise how to post it. Thanks!
Sub ImportIntoAccess()
Sheets("RC").Select
Range("b2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("A1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("b1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("c1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("h2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("d1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("e2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Loans"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
Range("G2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "3"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
Sheets("RC").Select
Range("b2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("b1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("c1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("f2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("d1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("G1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "4"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
Sheets("RC").Select
Range("b2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("b1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("a2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("c1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("RC").Select
Range("g2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("AccessImport").Select
Range("d1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("G1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "5"
LastRow = Range("D" & Rows.Count).End(xlUp).Row
ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))
End Sub
Sub Delete_Chg_Total_zero()
Dim r As Long
Dim LastRow As Long
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
For r = LastRow To 1 Step -1
If Cells(r, 4) = 0 Then
Rows(r).Delete
End If
Next r
End Sub
Here is the link to my spreadsheet
https://drive.google.com/file/d/11xG_cbu-HglAqX6a8XwjuolzHOmC3za7/view?usp=drivesdk
Or if this is not allowed please advise how to post it. Thanks!