Results 1 to 3 of 3

Thread: VBA and Excel

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    23

    Talking

    I am having a problem with a macro i have to write. I am trying to walk through lets say cells F1-F10. I must check each cell's value in this range and if it is greater than one i must do something. I am not sure however how to walk through the cell's value. Any help would be greatly appriciated.

    Steve Warker
    Stephen Warker

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    80

    Lightbulb

    You're working with excel, right?

    OK, the simplest trick (without presenting code) is to record the macro in Excel and then edit the macro to look what has been written.
    A simple way to learn some excel-basic.

    I've made a small program that also checks values in cells, but it's to long ago to remember, sorry.
    You probably need the .cells property (maybe:
    Cells(A1, C1).Value = "2" )

    Just try to let the macro recorder do your job...

    good luck !

    Fedor

    (don't hesitate to ask more questions)

  3. #3
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    Code:
    Dim rng As Range, rng1 As Range, rng2 As Range, cell As Range
      '  get contiguous range of cells below start cell
      Set rng1 = .Range("F1")
      Set rng2 = rng.End(xlDown)
      Set rng = Range(rng1, rng2)
      '  excel VBA is a RAM pig
      '  as a general rule, always free what you can.
      Set rng1 = Nothing
      Set rng2 = Nothing
    '    you could skip the above and simply use
    '  Set rng = .Range("F1:F10")
    '    but thought it might give you a few ideas...
    
    ' Irerate range
      For Each cell In rng
        Msgbox "Value of cell " & cell.address & " is " & cell.value
      Next cell
      Set rng = nothing
      Set cell = nothing

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