ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro help (https://www.excelbanter.com/excel-discussion-misc-queries/251712-macro-help.html)

puiuluipui

macro help
 
Hi, i need a macro to look in column B for a date ( 12/01 ) and then to add
the date to column A till last filled cell in A.

EX: (this is now)

A B
12/01
1 07:53:20
2 07:53:21
3 07:53:22
4 08:01:21
5 08:01:31
6 08:01:32
12/02
8 08:01:36
9 08:01:38
10 08:14:04
11 08:14:09

Ex: (after macro)
12/01
01.12.2009 07:53:20
01.12.2009 07:53:21
01.12.2009 07:53:22
01.12.2009 08:01:21
01.12.2009 08:01:31
01.12.2009 08:01:32
12/02
02.12.2009 08:01:36
02.12.2009 08:01:38
02.12.2009 08:14:04
02.12.2009 08:14:09
If in column A is a blank cell, in next cell in column B is a date.
Can this be done?
Thanks!

Jacob Skaria

macro help
 
Try the below

Sub Macro()
Dim lngRow As Long, varDate As Variant
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) = "" Then
varDate = Range("B" & lngRow)
Else
Range("A" & lngRow) = varDate
End If
Next
End Sub


--
Jacob


"puiuluipui" wrote:

Hi, i need a macro to look in column B for a date ( 12/01 ) and then to add
the date to column A till last filled cell in A.

EX: (this is now)

A B
12/01
1 07:53:20
2 07:53:21
3 07:53:22
4 08:01:21
5 08:01:31
6 08:01:32
12/02
8 08:01:36
9 08:01:38
10 08:14:04
11 08:14:09

Ex: (after macro)
12/01
01.12.2009 07:53:20
01.12.2009 07:53:21
01.12.2009 07:53:22
01.12.2009 08:01:21
01.12.2009 08:01:31
01.12.2009 08:01:32
12/02
02.12.2009 08:01:36
02.12.2009 08:01:38
02.12.2009 08:14:04
02.12.2009 08:14:09
If in column A is a blank cell, in next cell in column B is a date.
Can this be done?
Thanks!


puiuluipui

macro help
 
Hi Jacob. It's working great!
But after the macro i will need to search for empty cells in A column and
detele entire row.
Can this be done?
Thanks allot!

"Jacob Skaria" a scris:

Try the below

Sub Macro()
Dim lngRow As Long, varDate As Variant
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) = "" Then
varDate = Range("B" & lngRow)
Else
Range("A" & lngRow) = varDate
End If
Next
End Sub


--
Jacob


"puiuluipui" wrote:

Hi, i need a macro to look in column B for a date ( 12/01 ) and then to add
the date to column A till last filled cell in A.

EX: (this is now)

A B
12/01
1 07:53:20
2 07:53:21
3 07:53:22
4 08:01:21
5 08:01:31
6 08:01:32
12/02
8 08:01:36
9 08:01:38
10 08:14:04
11 08:14:09

Ex: (after macro)
12/01
01.12.2009 07:53:20
01.12.2009 07:53:21
01.12.2009 07:53:22
01.12.2009 08:01:21
01.12.2009 08:01:31
01.12.2009 08:01:32
12/02
02.12.2009 08:01:36
02.12.2009 08:01:38
02.12.2009 08:14:04
02.12.2009 08:14:09
If in column A is a blank cell, in next cell in column B is a date.
Can this be done?
Thanks!



All times are GMT +1. The time now is 12:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com