Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Help with 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.programming
external usenet poster
 
Posts: 7
Default Help with filling empty cells with string + row()


if cells(1,1) < "" then cells(2,1) = cells(1,1) & " " & cells(2,1).row

you can make use of a variable in the cells function.
e.g. cells(i,1)

HTH

Andrew Bourke

John Smith wrote:
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

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


Hello John,

Replace this line of code...
activecell.offset(1,0).select


With...

With ActiveCell
..Offset(1, 0).Value = .Text & .Row
End With

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=561330

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
filling in empty cells - stumped-in-excel[_2_] Excel Discussion (Misc queries) 7 June 13th 09 07:39 AM
Help on filling empty cells with string + row() John Smith Excel Discussion (Misc queries) 1 July 14th 06 04:44 AM
Filling empty cells with a value Ian Richardson ACITP Excel Discussion (Misc queries) 4 May 17th 06 03:25 PM
Filling in empty cells in columns koba Excel Discussion (Misc queries) 2 November 8th 05 10:03 PM
Filling empty cells with contents from another cell [email protected] Excel Programming 5 October 3rd 05 09:48 PM


All times are GMT +1. The time now is 06:39 PM.

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"