Looping Formula? VBA

Zains

New Member
Joined
Apr 22, 2013
Messages
17
Hey guys/girls,

My first post!

I was originally trying to run this formula, but found that I couldnt autofill a filtered selection. heres the code:

Code:
Range("I1").Select    ActiveCell.FormulaR1C1 = _
        "=IF(RC[-2]=""dpd"",HYPERLINK(""http://www.dpd.co.uk/tracking/quicktrack.do?search.consignmentNumber=""&RC[-1]&""&search.searchType=16&search.javascriptValidated=0&appmode=guest""))"
    Range("I1").Select
    Selection.AutoFill Destination:=Range("i1:i" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillCopy
     Range("I2").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    
    Range("A1:I1").Select
    ActiveSheet.Range("A1:i1").AutoFilter Field:=9, Criteria1:="FALSE"
       Range("I2").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(R[-1]C[-2]=""City Link"",HYPERLINK(""http://www.packagetrackr.com/track/citylink/""&R[-1]C[-1]&""""))"
      Range("I2").Select
    Selection.AutoFill Destination:=Range("i2:i" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillCopy
    
    Range("A1:I1").Select
    ActiveSheet.Range("A1:i1").AutoFilter Field:=9, Criteria1:="FALSE"
    Range("i2").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(R[-1]C[-2]=""hermes"",HYPERLINK(""http://www.hermes-europe.co.uk/tracker.html?trackingNumber=""&R[-1]C[-1]&""&Postcode=""&R[-1]C[-4]&R[-1]C[-3]&""""))"
      Range("I2").Select
    Selection.AutoFill Destination:=Range("i2:i" & Range("A" & Rows.Count).End(xlUp).Row), Type:=xlFillCopy

Maybe looping would be better?

I cant seem to autofill just the filtered choice.

I have about 20 values in Column G, and different data in Column H. Depending on what column G is, a different hyperlink URL has to be applied.

EG.

Cell G2: City Link
Cell H2: 12345

If Cell G2 = City Link, then Column I2 = HYPERLINK("http://www.packagetrackr.com/track/citylink/"&H2&")

Any suggestions would be fantastic!

Thanks guys/girls!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi
Thanks for the feedback.
Pleased to have helped you solve your problem.
Good luck with your project.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

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