Here's my code. It's in two parts b/c it's lengthy. And thanks again for your
help.
Sub update()
'
' update Macro
' Macro recorded 3/30/2009 by rblakeman
'
'
'Begin update
Sheets(Array("bluecard_homeplanaid", "bzv", "kpx", "uco", "hvu",
"generic", "bnl", "eca", "fus", "och", "rkk", "hbg", "lmp", "nfh")).Copy
Sheets("bluecard_homeplanaid").Select
ActiveSheet.Unprotect
Range("L1").Clear
' BZV
Range("A4").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("A4").Select
Sheets("bzv").Select
'Import
Range("B2").Select
Dim ans1 As Long
ans1 = MsgBox("Import Data for ""BZV""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans1 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "BZV"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("kpx").Select
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' END BZV
'IMPORT KPX
Range("B2").Select
Dim ans2 As Long
ans2 = MsgBox("Import Data for ""KPX""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans2 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "KPX"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("uco").Select
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' END KPX
'IMPORT UCO
Range("B2").Select
Dim ans3 As Long
ans3 = MsgBox("Import Data for ""UCO""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans3 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "UCO"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("hvu").Select
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
'END UCO
'IMPORT HVU
Range("B2").Select
Dim ans4 As Long
ans4 = MsgBox("Import Data for ""HVU""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans4 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "HVU"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("generic").Select
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
'END HVU
'IMPORT GENERIC
Range("B2").Select
Dim ans5 As Long
ans5 = MsgBox("Import Data for ""Generic""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans5 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "GENERIC"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("bnl").Select
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' END GENERIC
'IMPORT BNL
Range("B2").Select
Dim ans6 As Long
ans6 = MsgBox("Import Data for ""BNL""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans6 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "BNL"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("eca").Select ' IF A NEW TAB IS CREATED THEN CHANGE THE SHEET
NAME TO RELFECT NEW TAB
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' End BNL
'IMPORT ECA
Range("B2").Select
Dim ans7 As Long
ans7 = MsgBox("Import Data for ""ECA""?", vbYesNo + vbQuestion +
vbDefaultButton2)
' ENER NEW GROUP ACRONYM ABOVE
If ans7 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "ECA" ' ENTER NEW GROUP ACRONYM
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("fus").Select ' IF A NEW TAB IS CREATED THEN CHANGE THE SHEET
NAME TO RELFECT NEW TAB
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' End ECA
'IMPORT FUS
Range("B2").Select
Dim ans8 As Long
ans8 = MsgBox("Import Data for ""FUS""?", vbYesNo + vbQuestion +
vbDefaultButton2)
' ENER NEW GROUP ACRONYM ABOVE
If ans8 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "FUS" ' ENTER NEW GROUP ACRONYM
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("och").Select ' IF A NEW TAB IS CREATED THEN CHANGE THE SHEET
NAME TO RELFECT NEW TAB
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' End FUS
'Import OCH
Range("B2").Select
Dim ans9 As Long
ans9 = MsgBox("Import Data for ""OCH""?", vbYesNo + vbQuestion +
vbDefaultButton2)
' ENER NEW GROUP ACRONYM ABOVE
If ans9 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "OCH" ' ENTER NEW GROUP ACRONYM
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("rkk").Select ' IF A NEW TAB IS CREATED THEN CHANGE THE SHEET
NAME TO RELFECT NEW TAB
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' End OCH
'Import RKK
Range("B2").Select
Dim ans10 As Long
ans10 = MsgBox("Import Data for ""RKK""?", vbYesNo + vbQuestion +
vbDefaultButton2)
' ENER NEW GROUP ACRONYM ABOVE
If ans10 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "RKK" ' ENTER NEW GROUP ACRONYM
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("hbg").Select
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' End RKK
'IMPORT HBG
Range("B2").Select
Dim ans11 As Long
ans11 = MsgBox("Import Data for ""HBG""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans11 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "HBG"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("LMP").Select ' IF A NEW TAB IS CREATED THEN CHANGE THE SHEET
NAME TO RELFECT NEW TAB
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' End HBG
'IMPORT LMP
Range("B2").Select
Dim ans12 As Long ' Change XXX to next number in sequence
ans12 = MsgBox("Import Data for ""LMP""?", vbYesNo + vbQuestion +
vbDefaultButton2)
' ENER NEW GROUP ACRONYM ABOVE
If ans12 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "LMP" ' ENTER NEW GROUP ACRONYM
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Sheets("NFH").Select ' IF A NEW TAB IS CREATED THEN CHANGE THE SHEET
NAME TO RELFECT NEW TAB
Else
ActiveSheet.Next.Select
On Error Resume Next
End If
' End LMP
'IMPORT NEW TAB
' Range("B2").Select
' Dim ansXXX As Long ' Change XXX to next number in sequence
' ansXXX = MsgBox("Import Data for ""XXX""?", vbYesNo + vbQuestion +
vbDefaultButton2)
' ENER NEW GROUP ACRONYM ABOVE
' If ansXXX = vbYes Then
' Range("B2").Select
' Selection.QueryTable.Refresh BackgroundQuery:=False
' Range("A2").Select
' Range(Selection, Selection.End(xlDown)).ClearContents
'Update
' Range("A2").Select
' Range("A2") = "XXX" ' ENTER NEW GROUP ACRONYM
' If Range("B3") = "" Then
' do nothing
' Else
' LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
' col = ActiveCell.Column
' FormulaRow = ActiveCell.Row
' Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
' End If
'copy paste
' LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
' Range("A2:G" & LastRow).Select
' Selection.Copy
' Sheets("bluecard_homeplanaid").Select
' With Columns(1)
' Set C = .Find(what:="", after:=Cells(3, 1))
' C.Select
' End With
' ActiveSheet.Paste
' Sheets("XXX").Select ' IF A NEW TAB IS CREATED THEN CHANGE THE SHEET
NAME TO RELFECT NEW TAB
'Else
'ActiveSheet.Next.Select
'On Error Resume Next
'End If
' End NEW TAB
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'NEW TAB ABOVE 'NEW TAB ABOVE 'NEW TAB ABOVE 'NEW TAB ABOVE 'NEW TAB ABOVE
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'IMPORT NFH (FINAL IMPORT)
Range("B2").Select
Dim ans750 As Long
ans750 = MsgBox("Import Data for ""NFH""?", vbYesNo + vbQuestion +
vbDefaultButton2)
If ans750 = vbYes Then
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("A2").Select
Range(Selection, Selection.End(xlDown)).ClearContents
'Update
Range("A2").Select
Range("A2") = "NFH"
If Range("B3") = "" Then
' do nothing
Else
LastRow = ActiveCell.Offset(0, 3).End(xlDown).Row
col = ActiveCell.Column
FormulaRow = ActiveCell.Row
Range(Cells(FormulaRow, col), Cells(LastRow, col)).FillDown
End If
'copy paste
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & LastRow).Select
Selection.Copy
Sheets("bluecard_homeplanaid").Select
With Columns(1)
Set C = .Find(what:="", After:=Cells(3, 1))
C.Select
End With
ActiveSheet.Paste
Else
Sheets("bluecard_homeplanaid").Select
On Error Resume Next
End If
' END NFH
' ***** DO NOT PUT ANOTHER IMPORT HERE. IT MUST BE PLACED BEFORE NFH ******