+ Reply to Thread
Results 1 to 6 of 6

Giving HyperLinks in Workbook

  1. #1
    Registered User
    Join Date
    06-21-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    81

    Giving HyperLinks in Workbook

    The below provided VBA Code is working fine. Still, I want to know few things.
    1. Why we have used H
    2. I did not use any Dim statements. still code is working.

    Could some one please tell me what makes this code working properly

    Please Login or Register  to view this content.
    Thanks in Advance

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Giving HyperLinks in Workbook

    Hello theprincesunil ,

    It looks like the author of the macro used "H" to indicate the Hyperlink's row.

    Unless you have "Option Explicit" at the top of a Standard VBA module, VBA will not force you to declare the variables and their types. If you do not use the Dim statement the variable is typed as a Variant by default.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,812

    Re: Giving HyperLinks in Workbook

    H is a counter that gets incremented from 1 up to the number of worksheets that you have. It is used a few times within Cells(... , and as such it controls the row where the hyperlink is written to.

    Although you should declare the variables and specify the type, if you don't do so then Excel will treat them as type Variant (which use up more memory than Long, which could have been used in this case).

    Hope this helps.

    Pete

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,605

    Re: Giving HyperLinks in Workbook

    H is just a variable which allows you to determine which row to put your headings. In this case, they are going in row 1.

    You don't have to Dim variables, although it is good practice to do so ... both from an efficiency point of view and to avoid typing errors when you actually use variables. If you use Option Explicit, you are forced to Dim all variables or the code will not compile.

    A variable will take whatever data you want to put in it but, if you expect text, you should define it as String. If it's numeric, it can be Integer, Long, Double, etc. I usually define variables relating to row numbers as long but, in this case, Integer would be fine ... it's just a counter ... assuming there won't be a great number of rows.

    Hope that provides the clarification you were seeking.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    06-21-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: Giving HyperLinks in Workbook

    Thanks to All of you for making me to understand

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,605

    Re: Giving HyperLinks in Workbook

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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