Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default NEWBIE: How can I do a "soft reference" in Excel/VBA?

Hey all,

I'm trying to turn a row of data into multiple rows, as
such:
a b c 1 2 3 --- "a b c 1" and "a b c 2" and "a b c 3."

I need this to work such that if I click on row 1, it will
insert 3 rows, then do the appropriate fill, cut, and
paste. My first attempt with a macro didn't work - it was
a "hard" or "absolute" reference, so it would always do
the operations on the same row.

I tried modifying the code using "Selection.", but that
didn't work either, as I guess the selection changes each
time.

How can I move/operate relative to the cell that is
selected when the macro is run? I have found something
called Selection.Address, but I can't figure out how to
move around after that (i.e. softcode: select
Selection.Address, Selection.Address+2; fill down 5;
select Selection.Address+3; cut, paste Selection.Address
(+1, +3).

Thanks!
Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default NEWBIE: How can I do a "soft reference" in Excel/VBA?

For starters, you can use variables to achieve this sort of task like in
this case, setup a range object.

Dim CurRng as Range
Set CurRng = Selection

By doing this, even if the selection changes, the variable won't.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Dave" wrote in message
...
Hey all,

I'm trying to turn a row of data into multiple rows, as
such:
a b c 1 2 3 --- "a b c 1" and "a b c 2" and "a b c 3."

I need this to work such that if I click on row 1, it will
insert 3 rows, then do the appropriate fill, cut, and
paste. My first attempt with a macro didn't work - it was
a "hard" or "absolute" reference, so it would always do
the operations on the same row.

I tried modifying the code using "Selection.", but that
didn't work either, as I guess the selection changes each
time.

How can I move/operate relative to the cell that is
selected when the macro is run? I have found something
called Selection.Address, but I can't figure out how to
move around after that (i.e. softcode: select
Selection.Address, Selection.Address+2; fill down 5;
select Selection.Address+3; cut, paste Selection.Address
(+1, +3).

Thanks!
Dave



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
[newbie] Macro for "copy and paste" Jon Excel Discussion (Misc queries) 1 April 2nd 09 10:36 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


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