Combine data from multiple cells into one cell while in a loop

Brandon M

Board Regular
Joined
Sep 18, 2015
Messages
66
Hello everyone,

I've be wrestling with this code for days, and I'm finally getting it to where I want it. One problem I'm having right now is combining data from two cells into one cell and getting it to iterate down the column:

I have a data column, but unfortunately the automatically generated file separates hours minutes and seconds. I need to put the hours and minutes into a single cell on another sheet and also have it iterate the same way the rest of the data does. It should pull data from my specified starting point and then every 76th cell in the same column. I have all but the time working properly at this point.

I've included the code below. Thanks in advance for any help.

There is more code above what is shown below, but that all seems to be working fine.

Code:
Dim dateRowTo As Long: dateRowTo = 3 'row copied data begins to appear in
Dim dateRowFrom As Long: dateRowFrom = 6 'row data is copied from
Dim modeRowTo As Long: modeRowTo = 3
Dim modeRowFrom As Long: modeRowFrom = 11
Dim AxATo As Long: AxATo = 3
Dim AxAFrom As Long: AxAFrom = 31
Dim AxCTo As Long: AxCTo = 3
Dim AxCFrom As Long: AxCFrom = 60
Dim TimehourTo As Long: TimehourTo = 3
Dim TimehourFrom As Long: TimehourFrom = 7
Dim TimeminTo As Long: TimeminTo = 3
Dim TimeminFrom As Long: TimeminFrom = 7
Dim timeto As Long: timeto = 3
Dim timefrom As Long: timefrom = 7
max = wsraw.UsedRange.Rows.Count
Dim loop_ctr As Integer

With wsSPC
    nr = .Columns("A").Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row + 1

    For max = 1 To 60

'Date
        Worksheets("Mik4 Raw Data").Cells(dateRowFrom, 2).copy Cells(dateRowTo, "A")
        dateRowFrom = dateRowFrom + 76
        dateRowTo = dateRowTo + 1
'Mode
        Worksheets("Mik4 Raw Data").Cells(modeRowFrom, 2).copy Cells(modeRowTo, "C")
        modeRowFrom = modeRowFrom + 76
        modeRowTo = modeRowTo + 1
'Axis A
        Worksheets("Mik4 Raw Data").Cells(AxAFrom, 3).copy Cells(AxATo, "D")
        AxAFrom = AxAFrom + 76
        AxATo = AxATo + 1
'Axis C
        Worksheets("Mik4 Raw Data").Cells(AxCFrom, 3).copy Cells(AxCTo, "E")
        AxCFrom = AxCFrom + 76
        AxCTo = AxCTo + 1
'Time
        'Worksheets("Mik4 Raw Data").Cells(TimehourFrom, 3).copy Cells(TimehourTo, "B")
        'TimehourFrom = TimehourFrom + 76
        'TimehourTo = TimehourTo + 1
        .Range("B3") = (wsraw.Range("B7").Value - 12 & ":" & wsraw.Range("C7").Value)
        'Worksheets("Mik4 Raw Data").Cells(timefrom, 3 & 4).copy Cells(timeto, "B")
        'timefrom = timefrom + 76
        'timeto = timeto + 1
        loop_ctr = loop_ctr + 1
        
    Next max
    
End With

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,214,894
Messages
6,122,124
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top