Closed Thread
Results 1 to 6 of 6

Selected cell move one column to the right

  1. #1
    Registered User
    Join Date
    11-14-2003
    Posts
    32

    Selected cell move one column to the right

    Hi,

    I have the following piece of code:

    Set IRR = Application.InputBox( _
    prompt:="Select IRR Cell", Type:=8)

    Range("F8").GoalSeek Goal:=IRR, ChangingCell:=Range("F7")

    Assume the user selected the IRR cell to be F8, how do I change it to be G8, move one to the right, at the end of the code? And one down as well F9 (this is for a different variable I will create later).

    Thanks in advance for the help.

    Regards,

    Marcos

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon marksuza

    Have a look at the code below. I have renamed your IRR variable to NewIRR - there is already a VBA instruction called IRR, and this will cause havoc with your code, throwing errors up and all sorts :

    Please Login or Register  to view this content.
    You don't have to activate it - I have, but you can capture the address if you'd prefer for further manipulation.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    11-14-2003
    Posts
    32
    Reworked the code in a different way to look at the problem but it was not working, I was wondering if someone would be kind enough to pick out the mistakes. Basically the could is a "solver" problem where given an specific IRR and an input column from the user, MinP, I would get the other variable. The following is not working though:
    [/LIST]substitute values for variables in solver formula and [/LIST]the offset of MinP variable

    I would appreciate if somebody could help me. Thanks

    Sub GoalSeek()

    Dim IRR, MinP, Num, Row

    Set IRR = Application.InputBox( _
    prompt:="Select IRR Cell", Type:=8)

    Set MinP = Application.InputBox( _
    prompt:="Select mininum lead price", Type:=8)

    Row = 0

    Do While Row < 1


    SolverReset
    SolverOk SetCell:="$F$8", MaxMinVal:=3, ValueOf:=IRR, ByChange:="$F$6:$F$7"
    SolverAdd CellRef:="$F$6", Relation:=2, FormulaText:=MinP
    SolverOk SetCell:="$F$8", MaxMinVal:=3, ValueOf:=IRR, ByChange:="$F$6:$F$7"
    SolverSolve

    ActiveCell.Formula = Range("F7")

    ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate

    MinP.Offset(rowOffset:=1)

    Row = Row + 1

    Loop


    End Sub

  4. #4
    Registered User
    Join Date
    06-01-2009
    Location
    Seoul
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Selected cell move one column to the right

    I think it will exit your loop in the first sequence because Row is not smaller than 1.

    Do While Row < 1
    Row = Row + 1

  5. #5
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Selected cell move one column to the right

    As above, your loop will not loop, but will just execute the code once, but perhaps this is what you intended.

    Mainly I would point back at post #2:

    I have renamed your IRR variable to NewIRR - there is already a VBA instruction called IRR, and this will cause havoc with your code, throwing errors up and all sorts
    Until you have implemented that in YOUR code as well it would seem that any bug chasing is going to be futile.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Selected cell move one column to the right

    I would sincerely hope OP has resolved this by now...

    I am going to close the thread based on date.

Closed 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