Hi I am new to the macro and VBA world, but have picked up a lot from reading these forums so far. I am in need of some specific help though.
I have a macro called "CombinePenult" in workbook "experimental_form.xls" that basically is copying and pasting information from Sheet1 to the "name" sheet. That information is then copied. I usually have multiple experimental_form (ie. red1_form.xls, red2_form.xls) workbooks on my desktop minimized and actively pull them up, input a csv file, then run macro "CombinePenult". I then manually go to a second workbook "APS_date_company_datasummary.xls" and run macro "jak".
What I want to do is run the "CombinePenult" macro and have it activate the other workbook "APS_date_company_datasummary.xls" and then run macro "jak". I think I know how to do this if the "APS_date_company_datasummary.xls" file name doesn't change, however with each day and company the file name has to change. Is there a way to do this without having to edit the macro everytime. I was thinking if it could just look for the word datasummary in the name that would work since that part of the name never changes, but I am unsure how to do that or if it would work. The macro that works if the name doesn't change is listed below:
Sub CombinePenult()
'
' CombinePenult Macro
'
' Keyboard Shortcut: Option+Cmd+z
'
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Rows("11:11").Select
Selection.Delete Shift:=xlUp
Range("L8").Select
ActiveCell.FormulaR1C1 = "=R[-4]C[-10]&R[-4]C[-9]&R[-4]C[-8]"
Range("L8").Select
Selection.Copy
Sheets("name").Select
Range("H17:I17").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("D6:J6").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("name").Select
Range("A17").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet1").Select
Range("B9:H9").Select
Application.CutCopyMode = False
Selection.Copy
Range("C12").Select
ActiveSheet.Paste
Range("C10:I12").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("name").Select
Range("B23").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet1").Select
Range("D13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("name").Select
Range("B19:C19").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("F13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("name").Select
Range("E19:F19").Select
ActiveSheet.Paste
Range("B10:K10").Select
Application.CutCopyMode = False
Selection.Copy
Range("L10").Select
ActiveSheet.Paste
Range("A17:I17").Select
Application.CutCopyMode = False
Selection.Copy
Range("W10").Select
ActiveSheet.Paste
Range("B25:H25").Select
Application.CutCopyMode = False
Selection.Copy
Range("AG10").Select
ActiveSheet.Paste
Range("B23:H23").Select
Application.CutCopyMode = False
Selection.Copy
Range("AO10").Select
ActiveSheet.Paste
Range("B24:H24").Select
Application.CutCopyMode = False
Selection.Copy
Range("AW10").Select
ActiveSheet.Paste
Range("A28:K28").Select
Application.CutCopyMode = False
Selection.Copy
Range("BE10").Select
ActiveSheet.Paste
Range("L10:BO10").Select
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Clear
Range("B10").Select
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Workbooks("APS_date_company_datasummary.xls").Activate
Application.Run "APS_date_company_datasummary.xls!jak"
Application.ScreenUpdating = True
This worked when I tested it out, but again the name of the file "APS_date_company_datasummary.xls" changes regularly. Thank you in advance for any and all help! If there is anything else to help the macro as well please share as I am new to this and want to learn more about this.
Thanks,
Josh
Bookmarks