Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default referencing previously selected cells after macro execution begins

Apologies in advance for this stupid question. I am attempting to write a
short macro for a co-worker that allows a user to select a range of
spreadsheet data then save the selected data to a text file. How do you
select the data then start the macro and reference the selected data within
the macro? Everything I've tried chokes during debug. The operation seems
trivial but apparently to this old boy , isn't.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default referencing previously selected cells after macro execution begins

Sub MyMacro()
Dim rng as Range
On Error Resume Next
set rng = application.InputBox("With the mouse, " & _
"Select the range to convert to text file",type:=8)
On Error goto 0
if rng is nothing then
msgbox "You hit cancel, bye!"
exit sub
End if
rng.Select
msgbox rng.Address
End Sub

--
Regards,
Tom Ogilvy

"Glenn" wrote in message
...
Apologies in advance for this stupid question. I am attempting to write a
short macro for a co-worker that allows a user to select a range of
spreadsheet data then save the selected data to a text file. How do you
select the data then start the macro and reference the selected data

within
the macro? Everything I've tried chokes during debug. The operation

seems
trivial but apparently to this old boy , isn't.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default referencing previously selected cells after macro execution be

Tom, this is great for selecting the range but now what are the commands to
convert that range to text?

Thanks,
Mark Dyches


"Tom Ogilvy" wrote:

Sub MyMacro()
Dim rng as Range
On Error Resume Next
set rng = application.InputBox("With the mouse, " & _
"Select the range to convert to text file",type:=8)
On Error goto 0
if rng is nothing then
msgbox "You hit cancel, bye!"
exit sub
End if
rng.Select
msgbox rng.Address
End Sub

--
Regards,
Tom Ogilvy

"Glenn" wrote in message
...
Apologies in advance for this stupid question. I am attempting to write a
short macro for a co-worker that allows a user to select a range of
spreadsheet data then save the selected data to a text file. How do you
select the data then start the macro and reference the selected data

within
the macro? Everything I've tried chokes during debug. The operation

seems
trivial but apparently to this old boy , isn't.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default referencing previously selected cells after macro execution be

Here's a couple of links that'll get you further along.

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html

Mark Dyches wrote:

Tom, this is great for selecting the range but now what are the commands to
convert that range to text?

Thanks,
Mark Dyches

"Tom Ogilvy" wrote:

Sub MyMacro()
Dim rng as Range
On Error Resume Next
set rng = application.InputBox("With the mouse, " & _
"Select the range to convert to text file",type:=8)
On Error goto 0
if rng is nothing then
msgbox "You hit cancel, bye!"
exit sub
End if
rng.Select
msgbox rng.Address
End Sub

--
Regards,
Tom Ogilvy

"Glenn" wrote in message
...
Apologies in advance for this stupid question. I am attempting to write a
short macro for a co-worker that allows a user to select a range of
spreadsheet data then save the selected data to a text file. How do you
select the data then start the macro and reference the selected data

within
the macro? Everything I've tried chokes during debug. The operation

seems
trivial but apparently to this old boy , isn't.





--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default referencing previously selected cells after macro execution begins

Hi Glen;

Try this

Sub try()
Cells.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
Application.DisplayAlerts = False

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Administrator\My
Documents\MyTextFile.csv", _
FileFormat:=xlCSV, CreateBackup:=False
Range("A1").Select
End Sub


-----Original Message-----
Apologies in advance for this stupid question. I am

attempting to write a
short macro for a co-worker that allows a user to select

a range of
spreadsheet data then save the selected data to a text

file. How do you
select the data then start the macro and reference the

selected data within
the macro? Everything I've tried chokes during debug.

The operation seems
trivial but apparently to this old boy , isn't.
.



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
getting a simple macro to begin execution on the selected cell bolchman Excel Discussion (Misc queries) 2 February 2nd 07 08:59 PM
referencing selected cells [email protected] Excel Worksheet Functions 2 September 27th 06 07:22 PM
How do I get macro to unmerge cells that have been previously merg HankY New Users to Excel 2 December 8th 05 05:52 AM
Selection the previously selected cell David Excel Programming 3 June 3rd 04 02:16 PM
referencing values in adjacent cells to selected cell Darren Haslett Excel Programming 3 February 23rd 04 05:45 PM


All times are GMT +1. The time now is 01:08 PM.

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"