Results 1 to 3 of 3

Thread: Excel macro [RESOLVED]

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Excel macro [RESOLVED]

    I need an Excel macro that does the following:

    After I have selected a group of cells with the mouse, I exceute the macro (hotkey = ctrl/something) and the (numeric) contents of all the cells in the range gets divided by 1000. May be easy but I just can't figure out how to do it.
    Last edited by krtxmrtz; Jun 14th, 2004 at 01:42 AM.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    VB Code:
    1. 'DivideSelectedBy1000
    2.  
    3. Sub DivideSelectedBy1000()
    4.  
    5. 'Enumerate through the values
    6. Dim c As Integer ' Column Index
    7. Dim r As Integer ' Row Index
    8.  
    9. For c = 1 To Selection.Columns.Count
    10.     For r = 1 To Selection.Rows.Count
    11.         Selection.Item(r, c).Value = Selection.Item(r, c).Value / 1000
    12.     Next
    13.    
    14. Next
    15.  
    16. End Sub
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Thumbs up

    Thanks for guiding me through the jungle of Excel
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

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



Click Here to Expand Forum to Full Width