+ Reply to Thread
Results 1 to 6 of 6

Fill Link to a range according to cell value

Hybrid View

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Post Fill Link to a range according to cell value

    hi,
    i am using below code to fill external link to to my range and the name of the sheets are from cell's value

    Sub HaroonSidxxxx()
    Dim i As Long, y
    ReDim y(4 To Range("D" & Rows.Count).End(3).Row)
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For i = LBound(y) To UBound(y)
    Let Range("E" & i & ":F" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!D$1,"""")"
    Let Range("H" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!G$1,"""")"
    Let Range("J" & i & ":K" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!D$2,"""")"
    Let Range("M" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!G$2,"""")"
    
    Let Range("O" & i & ":P" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!D$3,"""")"
    Let Range("R" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!G$3,"""")"
    
    Let Range("T" & i & ":U" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!D$4,"""")"
    Let Range("W" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!G$4,"""")"
    
    
    Let Range("Y" & i & ":Z" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!D$5,"""")"
    Let Range("AB" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!G$5,"""")"
    
    Let Range("AD" & i & ":AE" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!D$6,"""")"
    Let Range("AG" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!G$6,"""")"
    
    Let Range("AI" & i & ":AJ" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!D$7,"""")"
    Let Range("AL" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & ".8.17.xlsb]SUMALL'!G$7,"""")"
    Next i
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    End Sub
    and i need to change in this part of the code
    ReDim y(4 To Range("D" & Rows.Count).End(3).Row)
    because of above the code fill data always from row 4 to last none blank row of column D
    i want if data is already filled till row 10 then this code fill data from row 10 instead of row4, if data is filled till 15 then code fill data from row 16 not from 4,

    thank you
    hope some one will work
    Use Code-Tags for showing your code :
    Please mark your question Solved if there has been offered a solution that works fine for you
    If You like solutions provided by anyone, feel free to add reputation using STAR *

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: Fill Link to a range according to cell value

    ................deleted...............
    Last edited by sintek; 08-11-2017 at 05:22 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Fill Link to a range according to cell value

    Found the accurate solution
    thanks to me

    Dim LastLine As Long
    Dim i As Long, y
    LastLine = Range("E34:E" & Rows.Count).End(xlUp).Row + 1
    
    'ReDim y(4 To Range("D34:D" & Rows.Count).End(3).Row) 'START FROM ROW 4
    On Error Resume Next
    ReDim y(LastLine To Range("D34:D" & Rows.Count).End(3).Row) ' START FROM LAST BLANK ROW
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For i = LBound(y) To UBound(y)
    Let Range("E" & i & ":F" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!D$1,"""")"
    Let Range("H" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!G$1,"""")"
    Let Range("J" & i & ":K" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!D$2,"""")"
    Let Range("M" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!G$2,"""")"
    
    Let Range("O" & i & ":P" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!D$3,"""")"
    Let Range("R" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!G$3,"""")"
    
    Let Range("T" & i & ":U" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!D$4,"""")"
    Let Range("W" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!G$4,"""")"
    
    
    Let Range("Y" & i & ":Z" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!D$5,"""")"
    Let Range("AB" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!G$5,"""")"
    
    Let Range("AD" & i & ":AE" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!D$6,"""")"
    Let Range("AG" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!G$6,"""")"
    
    Let Range("AI" & i & ":AJ" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!D$7,"""")"
    Let Range("AL" & i & "").Value = "=IFERROR('Z:\42766\Jan 2 Dec 2014\1.12.16\[" & Cells(i, "D").Value & "." & Range("A2").Value & "." & Range("A1").Value & ".xlsb]SUMALL'!G$7,"""")"
    Next i
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Last edited by HaroonSid; 08-11-2017 at 10:07 AM.

  4. #4
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Fill Link to a range according to cell value

    @sintek
    i just checked your msg which one you deleted,
    its the same same as i used

    Dim nRow As Long
    nRow = Range("D" & Rows.Count).End(xlUp).Row + 1
    ReDim y(nRow To Range("D" & Rows.Count).End(xlUp).Row + 1)
    but why you deleted this ???

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,288

    Re: Fill Link to a range according to cell value

    Hi HaroonSid

    I got caught up in a clients code that I completely forgot what I wanted to do and was not sure of your starting row....

  6. #6
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Fill Link to a range according to cell value

    ok
    thank you for reply

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to find text from a range in another range and fill a cell accordingly
    By aspadaro in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2017, 09:05 AM
  2. Specific number of cell to fill with color based in a dynamic cell range
    By Blue_Wings in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-01-2015, 09:46 AM
  3. Specific number of cell to fill with color based in a dynamic cell range
    By Blue_Wings in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-28-2015, 10:10 AM
  4. Replies: 3
    Last Post: 01-13-2015, 12:33 PM
  5. link cell contents for auto-fill oif second column
    By Notumbo in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-24-2009, 05:10 PM
  6. [SOLVED] Input range and link a cell
    By Jane in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-02-2006, 06:45 PM
  7. Replies: 2
    Last Post: 03-19-2006, 09:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1