Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tx12345
 
Posts: n/a
Default Allowing for variable cell reference in macro


Hi

What I'd like to figure out is how to get a macro to read from data
placed in a cell, and then apply that data to the macro.

like:

Sub Macro1()

Range("TBD<<").Select
Selection.sort Key1:=Range("I1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False

End Sub


where the range is read from some other cell on the spreadsheet. so the
macro reads what is in the cell telling it what range to sort, and then
enters that in the Range("").Select area of the macro.

Otherwise I have to create a separate macro for every area that might
possibly apply. I'd like to create an intelligent macro that I tell
what range to sort, or delete, or copy, or paste, etc, whatever I want
to happen with the range of cells I select.

Any ideas?

Thx


--
tx12345
------------------------------------------------------------------------
tx12345's Profile: http://www.excelforum.com/member.php...o&userid=24776
View this thread: http://www.excelforum.com/showthread...hreadid=495872

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default Allowing for variable cell reference in macro

Let's say that A1 contains the text Z100, the following:


Sub Macro1()
Dim s As String
s = Cells(1, 1)
Range(s).Select
End Sub

will get the contents of A1 (as a string) convert it into a range and select
that range. You could apply it to ranges of more than one cell.
--
Gary's Student


"tx12345" wrote:


Hi

What I'd like to figure out is how to get a macro to read from data
placed in a cell, and then apply that data to the macro.

like:

Sub Macro1()

Range("TBD<<").Select
Selection.sort Key1:=Range("I1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False

End Sub


where the range is read from some other cell on the spreadsheet. so the
macro reads what is in the cell telling it what range to sort, and then
enters that in the Range("").Select area of the macro.

Otherwise I have to create a separate macro for every area that might
possibly apply. I'd like to create an intelligent macro that I tell
what range to sort, or delete, or copy, or paste, etc, whatever I want
to happen with the range of cells I select.

Any ideas?

Thx


--
tx12345
------------------------------------------------------------------------
tx12345's Profile: http://www.excelforum.com/member.php...o&userid=24776
View this thread: http://www.excelforum.com/showthread...hreadid=495872


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tx12345
 
Posts: n/a
Default Allowing for variable cell reference in macro


nothing like a simple solution. many thanks!


--
tx12345
------------------------------------------------------------------------
tx12345's Profile: http://www.excelforum.com/member.php...o&userid=24776
View this thread: http://www.excelforum.com/showthread...hreadid=495872

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
Maintaining cell reference after sorting GRITS Excel Discussion (Misc queries) 2 April 30th 23 07:42 PM
how do I format a cell reference to move as source changes KGray Excel Worksheet Functions 1 August 13th 05 12:41 AM
copying cell names Al Excel Discussion (Misc queries) 12 August 11th 05 03:01 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


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