Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 62
Default Help on filling empty cells with string + row()

Say, A1 contains "apple", A3 "orange, A6 "berry", and A10
"banana". I would like to fill A2 with "apple 2", A4 "orange 4",
A5 "orange 5", A7 "berry 7", A8 "berry 8", A9 "berry 9". How
should I do it ?

How do I replace an empty cell with a string plus row #?


I tried the following but it did not work (forget about the loop
part because it's more complex than what I'm showing):

dim sCellContent as string

range("a1").select

if isempty(activecell) = false then
sCellContent = activecell.text
end if

activecell.offset(1,0).select

do while isempty(activecell) = false

activecell.text = sCellContent&" "&row()

loop

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Help on filling empty cells with string + row()


try this.

First select the range then run this macro

Sub copydown()
Dim myRange As Range
Set myRange = Selection
myText = ""
For Each cell In myRange
'set a new text value to use when it finds a non blank cell
If cell.Value < "" Then
myText = cell.Value
Else
cell.Value = myText & cell.Row
End If
Next cell
End Sub


--
Mallycat
------------------------------------------------------------------------
Mallycat's Profile: http://www.excelforum.com/member.php...o&userid=35514
View this thread: http://www.excelforum.com/showthread...hreadid=561323

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
List File Properties - Author SS Excel Worksheet Functions 1 June 23rd 06 04:56 PM
how insert same text in empty cells in column (10000 rows) bromptongadgets Excel Worksheet Functions 1 December 11th 05 03:13 PM
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
how do populate empty cells with the contents of populated cells . Jim99 Excel Discussion (Misc queries) 6 April 21st 05 05:44 PM
CountIF cells are not empty Wayne Excel Discussion (Misc queries) 3 January 6th 05 04:44 PM


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

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

About Us

"It's about Microsoft Excel"