Hello,
I am trying to reference a cell containing text information in cell "D5" on sheet "Company Lists" as apart of the PrToFileName parameter fir .PrintOut. The code works when manually replacing the "name" variable with the text inside quotation marks (ex. "AAPL").
Please see my code below:
Thank you in advance for any help.
I am trying to reference a cell containing text information in cell "D5" on sheet "Company Lists" as apart of the PrToFileName parameter fir .PrintOut. The code works when manually replacing the "name" variable with the text inside quotation marks (ex. "AAPL").
Please see my code below:
VBA Code:
Sub Macro2()
'
' Macro2 Macro
'
'
Dim filelocation As String
Dim name As String
Dim filename As String
Dim filetype As String
Dim file As String
Sheets("Company List").Range("D3") = 1
While Sheets("Company List").Range("D3") < 41299
filelocation = "G:\My Drive\BOYKO WEALTH\Boyko Data\"
name = Sheets("Company List").Range("D5").Value
filename = CStr(name)
filetype = "-Boyko-Data.pdf"
file = filelocation & filename & filetype
Sheets("Company List").Select
ActiveSheet.Range("D5").Copy
Sheets("ENTER").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C2").Select
Sheets("Data Reports").Select
Application.Wait (Now + TimeValue("0:00:05"))
ActiveSheet.PrintOut Copies:=1, collate:=True, Preview:=False, PrintToFile:=True, PrToFileName:=file
Sheets("Company List").Range("D3") = Sheets("Company List").Range("D3") + 1
Wend
End Sub
Thank you in advance for any help.