Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50057

Putting Together Date and Time into one column from two columns from another dynamic sheet

$
0
0
Hopefully this code will kind of make sense to you guys in explaining what I am trying to do.... Please see attached excel to see example. Sheet1 is the original data sheet and the data will be dynamic. I am trying to make it look like sheet2....
My Brain is Fried trying various ways to solve this. Looking for some help!

ExampleDateTime.xlsm

Code:

Sub Looper()
Dim NumRows As Long
Dim I As Range
Dim X As Range
Dim y As Integer
Dim Z As Range
Dim F
Dim Form As String
Dim G
Dim K As Integer
Dim myRange As Range

Sheets("Sheet1").Select
NumRows = WorksheetFunction.CountA(Range("A2:A50"))  'Count how many rows of data there are in Sheet 1

Sheets("Sheet2").Select
y = Range("A100000").End(xlUp).Offset(1, 0).Row  'Set y as the variable for blank row on Display sheet

'DATE/TIME
Sheets("Sheet1").Select
Set X = Range(Cells(2, 6), Cells(NumRows + 1, 7))  'Cells(2,6) is the start of the date column on Sheet 1  Cells(NumRows +1,7) is the End Range of the Time on the next column.  6 is the date column and 7                                                                      'is the time column

'**************************************************************************************************************************************
I am trying to cycle through each of the cells to INT and MOD both columns from sheet1 and place them into sheet2 into one column... Probably doesn't make too much sense here....
'**************************************************************************************************************************************[ATTACH]For K = 0 To NumRows
F = Worksheets("Sheet1").Cells(2 + K, 6)
G = Worksheets("Sheet1").Cells(2 + K, 7)
Sheets("Sheet2").Select
Range(Cells(y, 2), Cells(y + NumRows - 1, 2)).Formula = "=int(" & F & ")+mod(" & G & ")"
Next K


Viewing all articles
Browse latest Browse all 50057

Trending Articles