LucaS
LucaS

Reputation: 287

VBA Excel: How to jump 1 Cell to the right in my Loop?

I am trying to loop trough a huge excel document. The part that matters here is shown on the picture:

enter image description here

in the first column we have the working hours. the second column tells me how many full working days(8.2 hours per day). the third column tells me how many hours are left from the calculation of the full working days.

Now what i have to do with my code: I search the corresponding cell to the date in the date-column. then i fill in the working-hours per day. Ill show you my code first:

    Dim zelle_Start As String, zelle_End As String
    Dim full_Days As String, rest_hours As String
    Dim Date1 As Date
    Dim rngCell As Range, rngZelle As Range
    Dim i As Long
    Dim Destination As String


    For i = 14 To ActiveSheet.Cells(1816, 7).End(xlUp).Row
        full_Days = ActiveSheet.Cells(i, 8)
        rest_hours = ActiveSheet.Cells(i, 9)
        Date1 = ActiveSheet.Cells(i, 10)

        Set rngCell = Rows(9).Find(Date1, lookat:=xlWhole, LookIn:=xlFormulas)
        If Not rngCell Is Nothing Then
            Destination = rngCell.Address
        End If

        Destination = Replace(Destination, "9", i)

        ActiveSheet.Range(Destination).Select

        'Heres my Problem!
        For Days = 1 To full_Days
            Range(Destination).Value = "8.2"

        Next Days


    Next i

My problem is the "for loop" to fill in the working hours per day. How can i jump one cell to the right in the same line with every loop?? Basically i should look like the line where there is this red cell, its the example line(values are wrong) :)

I hope somebody has a good advice for me.

Upvotes: 0

Views: 1105

Answers (1)

LucaS
LucaS

Reputation: 287

The Solution was the Range.Offset Property..

Just one easy line of code does the desired jump to the right.

Range(Destination).Offset(rowOffset:=0, columnOffset:=1).Select

Thanks for the hint!

Upvotes: 1

Related Questions