VBA to search multiple cells.

Giulianeo

New Member
Joined
Sep 26, 2019
Messages
12
Hey guys,

I have this simple code to export as PDF, range AB52 is where it pulls the file name to save as... is it possible to have multiple ranges for the code to look for? I tried "range ("AB52:AB54")" would not work. Is this even possible? If one cell is empty look on the other ones for the file name?

Thank you!

VBA Code:
Sub Saveworksheetaspedfinwalmartfolder()

'Save Active Sheet(s) as PDF

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:="V:\DEPARTMENTS\TRAINING\COORDINATION\Invoicing Backup\" & Range("AB52"), openafterpublish:=True

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi

VBA Code:
Sub Saveworksheetaspedfinwalmartfolder()
'Save Active Sheet(s) as PDF
Dim i As Integer
For i = 52 to 54
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:="V:\DEPARTMENTS\TRAINING\COORDINATION\Invoicing Backup\" & Range("AB" & i), openafterpublish:=True
Next i
End Sub

Hope this will help
 
Upvote 0
Hi

VBA Code:
Sub Saveworksheetaspedfinwalmartfolder()
'Save Active Sheet(s) as PDF
Dim i As Integer
For i = 52 to 54
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:="V:\DEPARTMENTS\TRAINING\COORDINATION\Invoicing Backup\" & Range("AB" & i), openafterpublish:=True
Next i
End Sub

Hope this will help
Thank you! I was able to resolve it by using the IF statement to test different conditions however this will come in handy for something else I have! Would you happen to know if it is possible to..
VBA Code:
Sub Saveworksheetaspedfinwalmartfolder()

'Save Active Sheet(s) as PDF

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:="V:\DEPARTMENTS\TRAINING\COORDINATION\Invoicing Backup\" & Range("AB52"), openafterpublish:=True

End Sub

Add regular text to display after Range("AB52"), "_SS", so that the words _SS display after the text pulled from cell AB52?

Thank you!
 
Upvote 0

Forum statistics

Threads
1,212,929
Messages
6,110,741
Members
448,295
Latest member
Uzair Tahir Khan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top