kthorson16
New Member
- Joined
- Sep 3, 2015
- Messages
- 27
Looking for assistance with my current VBA Macro in excel 2010 that is to perform the following function.
Based on what is located in column I on tab "Covers" it will got to the correct macro, once it runs the needed macro I am wanting it to loop thru to the next row/cell in column "I" until it gets to a cell in column "I" that is blank. I am fairly new to the VBA macro writing world and am at a loss.
Can anyone provide some assistance?
Sub main_macro()
If Range("I7").Value = "A" Then
Call A_Macro
ElseIf Range("I7").Value = "B" Then
Call B_macro
ElseIf Range("I7").Value = "C" Then
Call C_macro
ElseIf Range("I7").Value = "D" Then
Call D_macro
Else
Return
End If
End Sub
Sub A_Macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim Location As String
Dim rDirList As String
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f802:aq803").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub
Sub B_macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim pRange As Range
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f803:aq805").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub
Sub C_macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim pRange As Range
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f804:aq806").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub
Sub D_macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim pRange As Range
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f1004:aq1006").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub
Based on what is located in column I on tab "Covers" it will got to the correct macro, once it runs the needed macro I am wanting it to loop thru to the next row/cell in column "I" until it gets to a cell in column "I" that is blank. I am fairly new to the VBA macro writing world and am at a loss.
Can anyone provide some assistance?
Sub main_macro()
If Range("I7").Value = "A" Then
Call A_Macro
ElseIf Range("I7").Value = "B" Then
Call B_macro
ElseIf Range("I7").Value = "C" Then
Call C_macro
ElseIf Range("I7").Value = "D" Then
Call D_macro
Else
Return
End If
End Sub
Sub A_Macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim Location As String
Dim rDirList As String
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f802:aq803").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub
Sub B_macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim pRange As Range
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f803:aq805").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub
Sub C_macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim pRange As Range
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f804:aq806").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub
Sub D_macro()
Dim wdMonth As String
Dim wdPath As String
Dim Details As String
Dim OWFP As String
Dim Tb As String
Dim PCP As String
Dim TWB As String
Dim NextRow As Range
Dim WKBK As Workbook
Dim TABNM As String
Dim WNAME As String
Dim pRange As Range
Application.ScreenUpdating = False
wdMonth = Sheets("Cover").Range("F7").Value
wdPath = Sheets("Cover").Range("G7").Value
OWFP = Sheets("Cover").Range("F7").Value
Details = Sheets("Cover").Range("H7").Value
TWB = ThisWorkbook.Name
Application.Workbooks.Open (wdPath)
Application.DisplayAlerts = False
Windows(TWB).Activate
NetNum = Application.WorksheetFunction.CountA(Range("$B$7:$B$51"))
For network = 7 To 6 + NetNum
wdMonth = Sheets("Cover").Cells(network, 6).Value
wdPath = Sheets("Cover").Cells(network, 7).Value
TABNM = Sheets("Cover").Cells(network, 8).Value
Windows(wdMonth).Activate
Sheets(Details).Select
Sheets(TABNM).Range("D2").Select
Sheets(TABNM).Range("D2").Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(wdMonth).Activate
Sheets(Details).Select
ActiveSheet.Range("f1004:aq1006").Select
Selection.Copy
Windows(TWB).Activate
Sheets("Details").Select
Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(wdMonth).Close SaveChanges:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Windows(TWB).Activate
Sheets("Cover").Select
Next
End Sub