Results 1 to 2 of 2

Thread: For in columns Range

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    this will work if there are no numbers below ActiveSheet.Range("[B to E]1").End(xlDown)
    Dim rnbSuma As Range
    Set rngSuma = Worksheets("hoja3").Range("F1")
    
    For columna = 2 to 5 'Column B to Column E
    rngSuma.Value = WorksheetFunction.Sum(Worksheets("hoja2").Columns(columna)) 
    Set rngSuma = rngSuma.Offset(1)
    Next columna

    Set Seleccion = Range(ActiveSheet.Range("B1"), ActiveSheet.Range("B1").End(xlDown))
    This is the same, but for any column number (columna)
    Set Seleccion = Range(ActiveSheet.Cells(1, columna), ActiveSheet.Cells(1, columna).End(xlDown))



    If you desire to move rngSuma to the right across columns, (F1 to G1 to H1 ...) then use .Offset(0 Rows, 1 columns)
    Set rngSuma = rngSuma.Offset(0, 1)
    Last edited by SamT; 12-30-2015 at 06:07 PM.
    Please take the time to read the Forum FAQ

Posting Permissions

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