Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2011, 06:38 AM
Learner7 Learner7 is offline How can I fill the below emty cells with above cell data? Windows XP How can I fill the below emty cells with above cell data? Office 2007
Advanced Beginner
How can I fill the below emty cells with above cell data?
 
Join Date: May 2010
Posts: 51
Learner7 is on a distinguished road
Default How can I fill the below emty cells with above cell data?

Hi,

How can I fill below cells which are blank (Empty Cells) with the above cell data? Like in the following example:

Column: A
Cell 1: 54001
Cell 2:
Cell 3: 54003
Cell 4:
Cell 5:
Cell 6:
Cell 7: 56321
Cell 8:
Cell 9:
-------------------------The reuslt should be like the following in RED:
Cell 1: 54001
Cell 2: 54001
Cell 3: 54003
Cell 4: 54003
Cell 5: 54003
Cell 6: 54003
Cell 7: 56321
Cell 8: 56321
Cell 9: 56321


Please help me with function/code. Because I need to modify hundreds of records on several sheets. It is very hard to do it manually.


Thanks.
Reply With Quote
  #2  
Old 06-27-2011, 11:06 AM
OTPM OTPM is offline How can I fill the below emty cells with above cell data? Windows 7 32bit How can I fill the below emty cells with above cell data? Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
Paste this code into a module in your workbook. It will deal with 1000 rows in Column A of your worksheet.
Let me know if you need to cover more columns.

Sub CellCheckForBlank()
'
' Check for Blank Cells and populate with value above
'
For Count = 1 To 1000
myVal = Range("A" & Count)
Range("A" & Count + 1).Select
If Range("A" & Count + 1) = "" Then
Range("A" & Count + 1) = myVal
End If
Next Count
End Sub


Tony (OTPM)
Reply With Quote
  #3  
Old 06-28-2011, 02:42 AM
Learner7 Learner7 is offline How can I fill the below emty cells with above cell data? Windows XP How can I fill the below emty cells with above cell data? Office 2007
Advanced Beginner
How can I fill the below emty cells with above cell data?
 
Join Date: May 2010
Posts: 51
Learner7 is on a distinguished road
Default

Quote:
Originally Posted by OTPM View Post
Hi
Paste this code into a module in your workbook. It will deal with 1000 rows in Column A of your worksheet.
Let me know if you need to cover more columns.

Sub CellCheckForBlank()
'
' Check for Blank Cells and populate with value above
'
For Count = 1 To 1000
myVal = Range("A" & Count)
Range("A" & Count + 1).Select
If Range("A" & Count + 1) = "" Then
Range("A" & Count + 1) = myVal
End If
Next Count
End Sub


Tony (OTPM)
Thanks for your reply. I tried this code but it is not working. I pasted this code in Excel work book in Visual Basic Module.

Please help me to figure it out.

Regards.
Reply With Quote
  #4  
Old 06-28-2011, 03:04 AM
OTPM OTPM is offline How can I fill the below emty cells with above cell data? Windows 7 32bit How can I fill the below emty cells with above cell data? Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
I tested it fully and it worked fine. Can you post a sample of your spreadsheet and I will attempt to provide a fix.
Kind regards
Tony(OTPM)
Reply With Quote
  #5  
Old 06-28-2011, 03:45 AM
Learner7 Learner7 is offline How can I fill the below emty cells with above cell data? Windows XP How can I fill the below emty cells with above cell data? Office 2007
Advanced Beginner
How can I fill the below emty cells with above cell data?
 
Join Date: May 2010
Posts: 51
Learner7 is on a distinguished road
Default

Quote:
Originally Posted by OTPM View Post
Hi
I tested it fully and it worked fine. Can you post a sample of your spreadsheet and I will attempt to provide a fix.
Kind regards
Tony(OTPM)
Thanks again. The following is the Test Excel work book attached for review.
Attached Files
File Type: xlsm Test.xlsm (12.0 KB, 11 views)
Reply With Quote
  #6  
Old 06-28-2011, 10:15 AM
OTPM OTPM is offline How can I fill the below emty cells with above cell data? Windows 7 32bit How can I fill the below emty cells with above cell data? Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
I tested the macro it it seemed to work fine for me. If I understand you correctly it should do the following:
1. As Cell A6 is blank it should copy the contents of Cell A5 into Cell A6.
2. As Cell A11 and A12 are blank then copy the contents of Cell A10 into Cells A11 and A12.
and so on..................
The macro will run for 1000 lines. So Cell A30 will be copied to Cells A31 through A1000.

If this is not what you want then please explain what you expect to happen and I will see what I can do.
Tony(OTPM)
Reply With Quote
  #7  
Old 06-28-2011, 11:55 AM
Learner7 Learner7 is offline How can I fill the below emty cells with above cell data? Windows XP How can I fill the below emty cells with above cell data? Office 2007
Advanced Beginner
How can I fill the below emty cells with above cell data?
 
Join Date: May 2010
Posts: 51
Learner7 is on a distinguished road
Default

Quote:
Originally Posted by OTPM View Post
Hi
I tested the macro it it seemed to work fine for me. If I understand you correctly it should do the following:
1. As Cell A6 is blank it should copy the contents of Cell A5 into Cell A6.
2. As Cell A11 and A12 are blank then copy the contents of Cell A10 into Cells A11 and A12.
and so on..................
The macro will run for 1000 lines. So Cell A30 will be copied to Cells A31 through A1000.

If this is not what you want then please explain what you expect to happen and I will see what I can do.
Tony(OTPM)
Yes. You are right. That is what I want. But when I tried it to copy the blank cells by dragging A5 Cell, it copies as follows:

CopyDataToCell-5
CopyDataToCell-6
CopyDataToCell-10
CopyDataToCell-11
CopyDataToCell-12

Actually it should copy:

CopyDataToCell-5
CopyDataToCell-5
CopyDataToCell-10
CopyDataToCell-10
CopyDataToCell-10

Where I am doing wrong in executing the function. Please help.

Thanks.
Reply With Quote
  #8  
Old 06-28-2011, 12:00 PM
OTPM OTPM is offline How can I fill the below emty cells with above cell data? Windows 7 32bit How can I fill the below emty cells with above cell data? Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
Now I understand why it did not run for you. You need to select the macro and choose run. It will then automatically fill the blank cells down to row 1000.
Hope this helps.
Tony(OTPM)
Reply With Quote
  #9  
Old 06-28-2011, 12:10 PM
Learner7 Learner7 is offline How can I fill the below emty cells with above cell data? Windows XP How can I fill the below emty cells with above cell data? Office 2007
Advanced Beginner
How can I fill the below emty cells with above cell data?
 
Join Date: May 2010
Posts: 51
Learner7 is on a distinguished road
Default

Quote:
Originally Posted by OTPM View Post
Hi
Now I understand why it did not run for you. You need to select the macro and choose run. It will then automatically fill the blank cells down to row 1000.
Hope this helps.
Tony(OTPM)
Wonderful! Thank you very much for your kind support.

Regards.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Move data from 1 cell to another cell Catalin.B Excel 1 06-25-2011 12:51 PM
How to fill a cell with random numbers to do calculations? zanat0s Excel 1 06-13-2011 10:33 AM
How can I fill the below emty cells with above cell data? How to combine different cells data in one cell? Learner7 Excel 1 07-28-2010 12:07 PM
How can I fill cell color starting from Cell D5 using Conditional formatting instead Learner7 Excel 0 07-08-2010 05:50 AM
Automatically entering/fill data in cells in Excel 2003 dipdog Excel 0 08-17-2006 08:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:15 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft