Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default 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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy data to the next empty cell in a column suruukko Excel Worksheet Functions 2 July 22nd 06 12:35 PM
copy content to first empty cell in column elrussell[_2_] Excel Programming 4 March 12th 06 04:16 PM
Copy from row above if cell is empty in column Jacky D. Excel Discussion (Misc queries) 2 December 20th 05 07:36 PM
Copy a value to the next empty cell in a column Pete Csiszar[_2_] Excel Programming 1 November 7th 04 07:26 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? Steven Rosenberg Excel Programming 0 August 5th 03 06:10 AM


All times are GMT +1. The time now is 10:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"