Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Find a specific text item and manipulate cells surrounding

Hello

Sorry for being rubbish but despite other examples i am still struggling. I
have the string "hello" as a column heading in a sheet. I wish to create a
macro that, for every time is run, assigns the cell value (eg A3 if "hello"
is in A3) to a variable.
i then have the code;

Range("A3").Select <--- "A3" will become the variable
Selection.EntireColumn.Insert

to insert a new column.
When the macro is re-run, the variable would hold the range "A4" in this
instance, and move the string "hello" into cell A5.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Find a specific text item and manipulate cells surrounding

Rather than storing the cell as a variable, it might be easier to just refind
the column every time you run the macro:

Dim Hello as Range
Set Hello = Range("1:1").Find("hello")
If Not (Hello Is Nothing) then Hello.EntireColumn.Insert

(by the way I think you mixed up column and row in the example - but the
technique could be modifed however necessary to meet your needs)
--
- K Dales


"RichHoughton" wrote:

Hello

Sorry for being rubbish but despite other examples i am still struggling. I
have the string "hello" as a column heading in a sheet. I wish to create a
macro that, for every time is run, assigns the cell value (eg A3 if "hello"
is in A3) to a variable.
i then have the code;

Range("A3").Select <--- "A3" will become the variable
Selection.EntireColumn.Insert

to insert a new column.
When the macro is re-run, the variable would hold the range "A4" in this
instance, and move the string "hello" into cell A5.

Thank you

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
To find rate of each item from item.xls and to copy price.xls pol Excel Discussion (Misc queries) 7 July 16th 09 12:49 AM
shortcut key for selecting the inactive cells surrounding a range Michele Excel Worksheet Functions 1 March 30th 08 03:02 AM
Can Excel find & sort one item in all the cells in a column? AHSinVT New Users to Excel 3 January 22nd 06 10:24 PM
can you find specific text in a string ignoring any other text chriscp Excel Discussion (Misc queries) 1 September 18th 05 09:54 PM
condition format for surrounding cells little rusty with excel Excel Discussion (Misc queries) 1 December 9th 04 07:35 AM


All times are GMT +1. The time now is 02:18 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"