Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to copy data to the next empty cell in a column | Excel Worksheet Functions | |||
copy content to first empty cell in column | Excel Programming | |||
Copy from row above if cell is empty in column | Excel Discussion (Misc queries) | |||
Copy a value to the next empty cell in a column | Excel Programming | |||
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? | Excel Programming |