![]() |
If the cell is empty, copy the value from a specific cell.
Hi there,
How do I write a macro that will check the cells to see if they are empty. If the cell J3 is empty, if it will copy the content from J2 onto J3. Do the same for J4, J5... J8. Thanks, Aline |
If the cell is empty, copy the value from a specific cell.
If IsEmpty(Range("J3")) Then Range("J2").Copy Range("J3")
-- Regards Dave Hawley www.ozgrid.com "Aline" wrote in message ... Hi there, How do I write a macro that will check the cells to see if they are empty. If the cell J3 is empty, if it will copy the content from J2 onto J3. Do the same for J4, J5... J8. Thanks, Aline |
If the cell is empty, copy the value from a specific cell.
I think this will do what you want...
Sub FillOutTheColumn() Dim Area As Range, LastRow As Long On Error Resume Next LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row For Each Area In Range("J2:J" & LastRow). _ SpecialCells(xlCellTypeBlanks).Areas Area.Value = Area(1).Offset(-1).Value Next End Sub -- Rick (MVP - Excel) "Aline" wrote in message ... Hi there, How do I write a macro that will check the cells to see if they are empty. If the cell J3 is empty, if it will copy the content from J2 onto J3. Do the same for J4, J5... J8. Thanks, Aline |
If the cell is empty, copy the value from a specific cell.
Are you trying to fill a column with values of the cell above?
Debra Dalgleish explains how: http://contextures.com/xlDataEntry02.html and a video http://www.contextures.com/xlVideos01.html#FillBlanks (There's code there, too -- if you really want.) Aline wrote: Hi there, How do I write a macro that will check the cells to see if they are empty. If the cell J3 is empty, if it will copy the content from J2 onto J3. Do the same for J4, J5... J8. Thanks, Aline -- Dave Peterson |
All times are GMT +1. The time now is 09:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com