+ Reply to Thread
Results 1 to 12 of 12

Loop in VBA

  1. #1
    Registered User
    Join Date
    09-08-2011
    Location
    BOLTON
    MS-Off Ver
    Excel 2003
    Posts
    66

    Loop in VBA

    Dear Excel Forum,

    Could you please tell me how to write a Loop in VBA
    to calculate the values of the formula below

    I would like to manually input a START NUMBER of say = 150 in the formula

    =((( ((3 + (9 + 12*START NUMBER)^0.5)/6)+INCREMENT)*6-3)^2-9)/12

    Then recalculate the formula with Increments of
    1,2,3,4,5,6,7,8,9,10,11,12, up to >> 24
    re-run the loop a second time with the increments of
    0.5, 1.5, 2.5, 3.5 ,4.5, 5.5, 6.5 ,7.5, 8.5, 9.5, 10.5, up to >> 23.5

    with the results as integers in a two comma separated lists

    increment = 0 =((( ((3 + (9 + 12*150)^0.5)/6)+0)*6-3)^2-9)/12 = 150
    increment = 1 =((( ((3 + (9 + 12*150)^0.5)/6)+1)*6-3)^2-9)/12 = 196
    increment = 2 =((( ((3 + (9 + 12*150)^0.5)/6)+2)*6-3)^2-9)/13 = 247
    increment = 3 =((( ((3 + (9 + 12*150)^0.5)/6)+3)*6-3)^2-9)/14 = 305

    See attached Excel spreadsheet " HEX Excel Forum "

    Thanking you in advance

    Best regards

    Derek
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Loop in VBA

    I can not understand your goal
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    09-08-2011
    Location
    BOLTON
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Loop in VBA

    Hello,

    The series of numbers are to plot Vertical Time Lines at those day intervals
    from a staring date in a Charting Program.

    Best regards,

    Derek

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Loop in VBA

    Hi, worswick25,

    could you elaborate why the last number is raised from the third entry on?
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Loop in VBA

    Here's my two cents, format cells to text

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-08-2011
    Location
    BOLTON
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Loop in VBA

    To All ,

    Thank you for your help.

    I am new to VBA it may take me time to set up your code

    Best regards,

    Derek

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Loop in VBA

    See if this is what you want.
    Attached Files Attached Files
    Last edited by sktneer; 10-19-2013 at 10:57 AM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Loop in VBA

    Quote Originally Posted by sktneer View Post
    See if this is what you want.
    Not sure the OP did say.
    two comma separated lists

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Loop in VBA

    Quote Originally Posted by worswick25 View Post
    To All ,

    Thank you for your help.

    I am new to VBA it may take me time to set up your code

    Best regards,

    Derek
    Click the button.
    Hit Alt & F11 to see the code
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-08-2011
    Location
    BOLTON
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Loop in VBA

    Hello,

    The formula is the Calculate the values a across the diameter (if that is the correct word)
    of a Gann Hexagon as shown in the attached file M&G East.pdf

    I did not attached his file originally as too much information can be confusing.

    I am having trouble with internet drop out due to thunder storm

    Thank you for your patience

    I hope that this helps,

    Best regards,

    Derek
    Attached Images Attached Images

  11. #11
    Registered User
    Join Date
    09-08-2011
    Location
    BOLTON
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Loop in VBA

    Hello Mr daves excel ,

    Thank you very much for your code and Excel spreadsheet.

    I works great.

    I tried to post a copy of Ganns' Hexagon as a PDF file but it would not upload the PDF
    coupled with having internet drop outs
    I have posted the Gann Hexagon as M &G East PNG file to explain what i am doing.

    Many thanks to you all

    Best regards,

    Derek

  12. #12
    Registered User
    Join Date
    09-08-2011
    Location
    BOLTON
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Loop in VBA

    Hi Mr Holger

    In your Email you asked
    "could you elaborate why the last number is raised from the third entry on?"

    increment = 2 =((( ((3 + (9 + 12*150)^0.5)/6)+2)*6-3)^2-9)/13 = 247
    increment = 3 =((( ((3 + (9 + 12*150)^0.5)/6)+3)*6-3)^2-9)/14 = 305

    This is a error on my part due to coping down in Excel
    the third and fourth lines devisor should again be /12
    corrected below:

    increment = 2 =((( ((3 + (9 + 12*150)^0.5)/6)+2)*6-3)^2-9)/12 = 247
    increment = 3 =((( ((3 + (9 + 12*150)^0.5)/6)+3)*6-3)^2-9)/12 = 305

    Thank you again for your help

    Best regards,

    Derek

+ 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. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  2. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  3. Macro Loop Broken. Detects Max but doesn't continue loop
    By herchenbach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2011, 12:17 PM
  4. Replies: 0
    Last Post: 07-20-2010, 11:42 AM
  5. Loop a column on Sheet1 and loop a row on Sheet2 to find a match
    By johnnywinter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-13-2009, 02:09 PM

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