If and Then with Loop Macro

jcarreon4ever

New Member
Joined
Aug 29, 2009
Messages
10
Hello all,
I am a beginner and I have an excel speadsheet with values in certain cells for a specific range (AA:BV). The number rows can vary each time I update the data.
What I am looking for is a macro to do the following:

If row cell has a value copy cell value and paste it to the right for each empty cell till it finds the next cell with a value, then go to the next row below and find the value copy it and paste it to the right of cell for each empty cell till it finds the next cell with a value, etc...

I would guess that a loop would work, but I do not know how to do it.

Any help would be greatly appreciated.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Untested but try this,

Sub test1

Dim i As Long
Dim cell as Range

Lastrow = Cells(row.count,1).End(xlUp).row
For i = 1 to Lastrow
For each cell in range("AA" & i,"BV" & i)
If Cell.value = "" Then
Cell.value = cell.Offset(0,-1).value
End if
Next cell
Next i

End Sub
 
Upvote 0
I have attached an example BELOW. So for example:
AA thru AJ would populate with 25 accross the row, then the row below, AD thru AI will be populated with 50 across, etc. etc etc... Any help is appeciated.

<TABLE style="WIDTH: 495pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=660><COLGROUP><COL style="WIDTH: 45pt; mso-width-source: userset; mso-width-alt: 2194" span=11 width=60><TBODY><TR style="HEIGHT: 10.5pt" height=14><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc 0.5pt solid; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; HEIGHT: 10.5pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 height=14 width=60>AA</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AB</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AC</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AD</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AE</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AF</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AG</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AH</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AI</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AJ</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AK</TD></TR><TR style="HEIGHT: 10.5pt" height=14><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc 0.5pt solid; BACKGROUND-COLOR: #dce6f1; HEIGHT: 10.5pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93 height=14>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201202</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201203</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201204</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201205</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201206</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201207</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201208</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201209</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201210</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl93>201211</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94 height=20>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD></TR><TR style="HEIGHT: 15pt; mso-height-source: userset" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94 height=20></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>50</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>50 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>50 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>50 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>50 </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>50</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94 height=20></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94 height=20></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94 height=20></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94 height=20></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94 height=20></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl94></TD></TR></TBODY></TABLE>
 
Upvote 0
Untested but try this,

Sub test2
Dim i As Long
Dim cell as Range

On Error Resume Next
For i = 1 to 33 ' put here how many rows u want to check
For each cell in range("AA" & i,"BV" & i)
If Cell.value >0 And Cell.Offset(0,1).value = "" Then
Cell.Offset(0,1).value = cell.value
End if
Next cell
Next i

End Sub
 
Upvote 0
Almost got it! If the cell value in AE3 = 25 and in the same row value in AJ3=25 (These 2 numbers will be the same always, but could vary in each row). Whats happening is that the cells in between are blank and need to be populated with the same number. Using the example above the number 25 will be populated in between (Cells AE3 thru AJ3). The span in the rows will vary. To go further, what I am doing is getting the start date and end date, so my macro is populating the value in the start date and end date, but where I am stuck is getting the value to populate in between the start and end date with what ever the value is for the start and end date. Hope this helps.
 
Upvote 0
Almost got it!
My macro is populating the start and End values, but where I am stuck is getting the value to populate in between the start and end with the same value
Where I have put populate, that is where the value from the start would be copied to. So the macro you wrote works but it continues past the Stop. I would need it to stop, then continue to the next row until the end on the columns.
<TABLE style="WIDTH: 540pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=720><COLGROUP><COL style="WIDTH: 45pt; mso-width-source: userset; mso-width-alt: 2194" span=12 width=60><TBODY><TR style="HEIGHT: 10.5pt" height=14><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc 0.5pt solid; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; HEIGHT: 10.5pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 height=14 width=60>AA</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AB</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AC</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AD</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AE</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AF</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AG</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AH</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AI</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AJ</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AA</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: #dce6f1; WIDTH: 45pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl92 width=60>AA</TD></TR><TR style="HEIGHT: 10.5pt" height=14><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc 0.5pt solid; BACKGROUND-COLOR: yellow; HEIGHT: 10.5pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94 height=14>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD><TD style="BORDER-BOTTOM: #cccccc 0.5pt solid; BORDER-LEFT: #cccccc; BACKGROUND-COLOR: yellow; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #cccccc 0.5pt solid" class=xl94>201201</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93 height=20> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl96>Start--></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl95>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl95>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl96><--Stop</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD></TR><TR style="HEIGHT: 15pt; mso-height-source: userset" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93 height=20> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl96>Start--></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl95>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl95>25</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl96><--Stop</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; HEIGHT: 15pt; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93 height=20> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl96>Start--></TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl95>50</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93>populate</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl95>50</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl96><--Stop</TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD><TD style="BORDER-BOTTOM: #d4d0c8; BORDER-LEFT: #d4d0c8; BACKGROUND-COLOR: #dce6f1; BORDER-TOP: #d4d0c8; BORDER-RIGHT: #d4d0c8" class=xl93> </TD></TR></TBODY></TABLE>
Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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