Results 1 to 4 of 4

Thread: Quick Excel Question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Quick Excel Question

    I have a spreadsheet

    it has about 4000 rows, but for 8 of the 125 columns i need to add 1 to each cell....how do I do this?

  2. #2
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711
    do you mean add 1 & (data) or just make every thing 1?

    PS: you should put this in the VBA or the VB Clasic section of VBforums.com
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    the data in all the cells are numeric, I want to mathamatically add 1 to every number

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929
    there are quicker ways, but this should work (untested):
    VB Code:
    1. 'this assumes xlSheet is an active Sheet object
    2.  
    3. Dim lRow as long, lCol as long
    4.  
    5. With xlSheet
    6.   '.Application.Visible = False     '(these will make it run faster)
    7.   '.Application.ScreenUpdating = False
    8.  
    9.   For lRow = 1 to .UsedRange.Rows.Count
    10.     For lCol = 1 to 8
    11.       '(you should probably check there is a number)
    12.       .Cells(lRow,lCol) = .Cells(lRow,lCol) + 1
    13.     Next lCol
    14.   Next lRow
    15.  
    16.   '.Application.Visible = True     '(restore)
    17.   '.Application.ScreenUpdating = True
    18. End With

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