+ Reply to Thread
Results 1 to 6 of 6

Excel 2007 : Change value of selected range using VBA

Hybrid View

ramia1983 Change value of selected... 01-18-2012, 06:48 PM
Rblack40 Re: Change value of selected... 01-18-2012, 06:51 PM
TMS Re: Change value of selected... 01-18-2012, 06:53 PM
tom1977 Re: Change value of selected... 01-18-2012, 06:55 PM
Rblack40 Re: Change value of selected... 01-18-2012, 07:12 PM
TMS Re: Change value of selected... 01-18-2012, 07:32 PM
  1. #1
    Registered User
    Join Date
    03-18-2008
    Posts
    17

    Change value of selected range using VBA

    How would i write the code?

    I want to be able to select a range in a worksheet and then the vba code should check if that current value is <50 and then change it to -9999 if it is. also i wanted to activate it using a shortcut...ctrl-j or something

  2. #2
    Registered User
    Join Date
    01-17-2012
    Location
    Orlando FL
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    22

    Re: Change value of selected range using VBA

    I have no clue on VBA either with custom functions.

  3. #3
    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
    48,489

    Re: Change value of selected range using VBA

    @Rblack40: and your point is ... ?


    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    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


  4. #4
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Change value of selected range using VBA

    theck this
    Sub aa()
    Dim c As Range
    For Each c In Selection
    If Not IsEmpty(c) Then
    If IsNumeric(c.Value) And c.Value < 50 Then
    c.Value = -9999
    End If
    End If
    Next
    End Sub
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  5. #5
    Registered User
    Join Date
    01-17-2012
    Location
    Orlando FL
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    22

    Re: Change value of selected range using VBA

    I posted a thread under User Defined Functions and have no clue of the VBA code.

  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
    48,489

    Re: Change value of selected range using VBA

    @Rblack40: again, your post does not comply with forum rules. It has nothing to do with the original question and adds no value. I trust that you are not just trying to up your post count.

+ 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