how to make a date & file name from a sheet become a parameter in a macro

akika

New member
Joined
Aug 5, 2018
Messages
7
Reaction score
0
Points
1
Excel Version(s)
2016
hi,
pls help.
i have a main excel 2016 with a vba code in a button.
In sheet param, column A is date and column B is file name.. After input the date DD-MON-YY
e.g "09-Oct-18" and file name can be anything prefix with the "_09-10-2018.xlsx" in that sheet 'Param'.


I want to use that data entry as parameter in the code.; How to do it?


Code:
 If Format(Range("A" & i).Value, "d-mmm-yy") = [B]"09-Oct-18"[/B] Then
   Range("B" & i).Select
   ActiveCell.FormulaR1C1 = _
             "=VLOOKUP(R2C1,'D:\akika\files\[[B]CATEGORY_99_TAS_09-10-2018.xlsx[/B]]Sheet1'!R2C1:R30C2,2,FALSE)"


    Range("G" & i).Select
    ActiveCell.FormulaR1C1 = _
        "='D:\akika\working\[consolidate.xlsx]Sheet1'!R4C3"
        
Else
   If Format(Range("A" & i).Value, "d-mmm-yy") = "15-Oct-18" Then
    Range("B" & i).Select
    ActiveCell.FormulaR1C1 = _
            "=VLOOKUP(R2C1,'D:\akika\files\[CATEGORY_99_TAS_15-10-2018.xlsx]Sheet1'!R2C1:R30C2,2,FALSE)"
   
    Range("G" & i).Select
    ActiveCell.FormulaR1C1 = _
       "='D:\akika\working\[consolidate.xlsx]Sheet1'!R4C3"
    
   End If
End If
a
 
Last edited by a moderator:
Hi
in the future please wrap your code with code tags ( click -Go advanced - select code - click the #button). I added the tags on your first post for you. Thx
 
cross posted without links:
https://chandoo.org/forum/threads/u...from-cells-to-be-in-the-vba-macro-code.39990/
https://www.mrexcel.com/forum/excel...e-file-name-sheet-become-parameter-macro.html
https://www.excelforum.com/excel-pr...om-a-sheet-become-a-parameter-in-a-macro.html

akika, for your information, you should always provide links to your cross posts.
This is a requirement, not just a request.
If you have cross posted at other places, please add links to them too.
Why? Have a read of http://www.excelguru.ca/content.php?184
 
Last edited:
Back
Top