none
how to add value into cell RRS feed

  • Question

  • Hello I have written code for adding the value into cells ..LIKE A1,A2,A3, and so on code is
    For i = 1 To XDim

    Range("A" & i) = start_point
    start_point = start_point + step_size

    Next i

    now i want to add value into cells by column wise for example:A1,B1,C1,D1,E1 and so on...
    may i no how can i use the for loop


    Tuesday, September 11, 2012 7:37 AM

Answers

  • For example like this:

        Dim lngCol As Long
        Dim lngLastCol As Long
        Dim start_point As Long
        Dim step_size As Long
    
        lngLastCol = 12 ' corresponds to column L
        start_point = 37
        step_size = 5
    
        For lngCol = 1 To lngLastCol
            Cells(1, lngCol).Value = start_point
            start_point = start_point + step_size
        Next lngCol


    Regards, Hans Vogelaar

    • Proposed as answer by ManjunathRV Tuesday, September 11, 2012 11:15 AM
    • Marked as answer by sahilsheik Tuesday, September 11, 2012 11:57 AM
    Tuesday, September 11, 2012 7:53 AM