View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Fuller John Fuller is offline
external usenet poster
 
Posts: 40
Default Combine date and time

Your code snippet works just fine. If you're trying to loop through
all the rows, then i would suggest this (assuming you want the result
to go into column A, and the date is in B and the time is in C):

LastRow=Range("A65532").End(xlUp).Row
For i = 1 to LastRow
Cells(i,1).Value = Cells(i,2).Value + Cells(i,3).Value
Next i
BN-CD wrote:
I'm sure this have been asked before, however I have searched several
different variations and can't seem to find the answer. I have 2
columns, one has a date and the other has a time. I have tried several
ways of combining these 2 columns with no success. I'm fairly new when
it comes to VBA code so sorry for the newbie question.
Here is the code I'm currently trying to use. When I run the macro I
get a runtime error 13, missmatch type.


Code:
--------------------
LastRow = Range("A65532").End(xlUp).Row
LastValue = Range("F" & LastRow).Value2 + 1
counter = 2
Do Until counter = LastValue + 1
Range("T" & counter).Value2 = Range("I" & counter).Value2 + Range("K" & counter).Value2
counter = counter + 1
Loop
--------------------

I then tried this code just to see if I was making an error with the
counter etc...

Code:
--------------------
Range("T2").Value2 = Range("I2").Value2 + Range("K2").Value2
--------------------


--
BN-CD
------------------------------------------------------------------------
BN-CD's Profile: http://www.excelforum.com/member.php...o&userid=35374
View this thread: http://www.excelforum.com/showthread...hreadid=573245