Trying to make a looping VBA statement

reasem

New Member
Joined
Nov 15, 2019
Messages
38
Hello I have a code that downloads pdfs from a URL in column F but I'm trying to get it to loop through multiple URLs and name each file based on the values adjacent in column E. Would it be 2 for each statements? or could I use an offset to pull the cells for the name?
VBA Code:
Dim c As Range

For Each c In Range("E3218:E3251")
mainUrl = "https://www.mysite/authenticate/credentials"
fileUrl = c
filePath = "C:\Users\reasem\Documents\files\" & "\" c.Offset(RowOffSet:=0, ColumnOffset:=1) ".PDF"

**REST OF CODE**

Offset isn't working because c.Offset is making it think the statement has ended.

Any help?

Thanks
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi! Are you ok?

Do you want that him get the text from first right column?

If this no work, do you can post a sheet image?

VBA Code:
Dim c As Range

For Each c In Range("E3218:E3251")
mainUrl = "https://www.mysite/authenticate/credentials"
fileUrl = c
filePath = "C:\Users\reasem\Documents\files\" & "\" c.Offset(0,1).Value & ".PDF"

**REST OF CODE**
 
Upvote 0
sorry i meant c.Offset(0,-1) but it says unexpected end of statement
 

Attachments

  • Capture.PNG
    Capture.PNG
    100.2 KB · Views: 4
Upvote 0
I think that you need ampersands around that offest

Rich (BB code):
filePath = "C:\Users\reasem\Documents\files\" & "\" & c.Offset(RowOffSet:=0, ColumnOffset:=1) & ".PDF"
 
Upvote 0
I think that you need ampersands around that offest

Rich (BB code):
filePath = "C:\Users\reasem\Documents\files\" & "\" & c.Offset(RowOffSet:=0, ColumnOffset:=1) & ".PDF"
yup this was it. I should proof read my code before making a post. Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

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