![]() |
For every empty cell in a column, copy the value from the above ce
Good afternoon!
I have a sheet which is keeping track of miscellaneous inventory items. In Column A, there are several cells with values of even numbers and the cell directly below that is empty. What I am trying to achieve is populating the empty cells to have a value of the cell above it (the even number value cell) plus 1. In other words, if the value of cell A:2 is 1000, then cell A:3 will be 1001. If the value of cell A:4 is 1200, then cell A:5 will be 1201 and so forth until the end of the column. Thank you, in advance, for your help! |
For every empty cell in a column, copy the value from the abovece
Hello
Try this: Sub FillIn() Dim TargetCell As Range Set TargetCell = Range("A2") Do Until TargetCell.Value = "" If TargetCell.Offset(1, 0).Value = "" Then TargetCell.Offset(1, 0) = TargetCell.Value + 1 Set TargetCell = TargetCell.Offset(2, 0) End If Loop End Sub Regards, Per On 22 Nov., 21:31, Charles Robe wrote: Good afternoon! I have a sheet which is keeping track of miscellaneous inventory items. In Column A, there are several cells with values of even numbers and the cell directly below that is empty. What I am trying to achieve is populating the empty cells to have a value of the cell above it (the even number value cell) plus 1. In other words, if the value of cell A:2 is 1000, then cell A:3 will be 1001. If the value of cell A:4 is 1200, then cell A:5 will be 1201 and so forth until the end of the column. Thank you, in advance, for your help! |
For every empty cell in a column, copy the value from the above ce
maybe something like this
Sub evenNumbers() Dim rng, cell As Range Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp)) For Each cell In rng If cell.Value Mod 2 = 0 Then If cell.Offset(1, 0).Value = "" Then cell.Offset(1, 0).Value = cell.Value + 1 Else End If End If Next cell End Sub "Charles Robe" wrote: Good afternoon! I have a sheet which is keeping track of miscellaneous inventory items. In Column A, there are several cells with values of even numbers and the cell directly below that is empty. What I am trying to achieve is populating the empty cells to have a value of the cell above it (the even number value cell) plus 1. In other words, if the value of cell A:2 is 1000, then cell A:3 will be 1001. If the value of cell A:4 is 1200, then cell A:5 will be 1201 and so forth until the end of the column. Thank you, in advance, for your help! |
For every empty cell in a column, copy the value from the abov
Thank you, both! Both functions worked out great!
"Mike" wrote: maybe something like this Sub evenNumbers() Dim rng, cell As Range Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp)) For Each cell In rng If cell.Value Mod 2 = 0 Then If cell.Offset(1, 0).Value = "" Then cell.Offset(1, 0).Value = cell.Value + 1 Else End If End If Next cell End Sub "Charles Robe" wrote: Good afternoon! I have a sheet which is keeping track of miscellaneous inventory items. In Column A, there are several cells with values of even numbers and the cell directly below that is empty. What I am trying to achieve is populating the empty cells to have a value of the cell above it (the even number value cell) plus 1. In other words, if the value of cell A:2 is 1000, then cell A:3 will be 1001. If the value of cell A:4 is 1200, then cell A:5 will be 1201 and so forth until the end of the column. Thank you, in advance, for your help! |
All times are GMT +1. The time now is 02:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com