Results 1 to 2 of 2

Thread: excel and vba

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    23

    Red face

    hey

    i have a program that looks like this:

    Sub B()
    Dim rng As Range, rng2 As Range, cell As Range

    Set rng = Range("F4.F66")

    For Each cell In rng
    If cell >= 1 Then
    ******

    End If
    Next cell

    Set rng = Nothing
    Set cell = Nothing


    where the stars are i need code that will take the data in column b,c,d,e,f,g of the cell that is selected and copy it into b101. any help?

    Steve
    Stephen Warker

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    Code:
    Sub B()
    Dim i As Integer, res As Integer, str As String
    Dim rng As Range, cell As Range
      Set rng = Range("F4:F66")
      For Each cell In rng
        If cell > 0 Then
          res = 0
          ' str = ""
          For i = 0 to 5
            res = res + cell.Offset(0, i - 4)
            ' str = str & cell.Offset(0, i - 4) & " "
          Next i 
          ActiveSheet.Range("B101") = res  ' or str...
          Exit For        
        End If
      Next cell
      Set rng = Nothing
      Set cell = Nothing
    End Sub
    [Edited by Mongo on 07-06-2000 at 03:46 PM]

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