Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ale ale is offline
external usenet poster
 
Posts: 14
Default selecting sheets within a macro

I would like to be able to click on the sheet I want within a macro and then
continue on with the macro code

for example this code chooses all the sheet within the test workbook and
puts a 0 in A1

Windows("test.xls").Activate
Sheets.Select
Range("A1").Select
ActiveCell.FormulaR1C1 = "0"
Range("A2").Select

instead I want the workbook to pop up so that I can click on a single sheet
I select
and put a 0 in only that single sheet





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default selecting sheets within a macro

Check this out:

Sub rangerover()
Dim r As Range
On Error Resume Next
Set r = Nothing
Set r = Application.InputBox("Select a cell with the mouse", Type:=8)
MsgBox ("Address is: " & r.Address)
MsgBox ("Worksheet is: " & r.Parent.Name)
MsgBox ("Workbook is: " & r.Parent.Parent.Name)
r.Parent.Parent.Activate
r.Parent.Activate
r.Select
r.Value = 0
End Sub

The code stops and asks the user to click any cell in any sheet of any open
workbook. The code the describes the cell, goes to the cell and puts zero in
that cell.
--
Gary''s Student
gsnu200710


"ale" wrote:

I would like to be able to click on the sheet I want within a macro and then
continue on with the macro code

for example this code chooses all the sheet within the test workbook and
puts a 0 in A1

Windows("test.xls").Activate
Sheets.Select
Range("A1").Select
ActiveCell.FormulaR1C1 = "0"
Range("A2").Select

instead I want the workbook to pop up so that I can click on a single sheet
I select
and put a 0 in only that single sheet





  #3   Report Post  
Posted to microsoft.public.excel.programming
ale ale is offline
external usenet poster
 
Posts: 14
Default selecting sheets within a macro

Thanks a bunch!! I think this will do the trick. I tested it out and it
seems to work well. I'm writing a bigger macro so I'll repost if I need more
help. I was hoping the answer was something simple like adding something to
sheets(...) but I guess not.

"Gary''s Student" wrote:

Check this out:

Sub rangerover()
Dim r As Range
On Error Resume Next
Set r = Nothing
Set r = Application.InputBox("Select a cell with the mouse", Type:=8)
MsgBox ("Address is: " & r.Address)
MsgBox ("Worksheet is: " & r.Parent.Name)
MsgBox ("Workbook is: " & r.Parent.Parent.Name)
r.Parent.Parent.Activate
r.Parent.Activate
r.Select
r.Value = 0
End Sub

The code stops and asks the user to click any cell in any sheet of any open
workbook. The code the describes the cell, goes to the cell and puts zero in
that cell.
--
Gary''s Student
gsnu200710



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
Help with Macro in selecting sheets. Ann New Users to Excel 4 March 30th 07 01:56 PM
selecting multiple sheets in a macro Big Al[_3_] Excel Programming 6 September 10th 05 10:38 PM
Selecting Sheets within a Macro esersen Excel Programming 1 October 28th 04 04:09 PM
Selecting all sheets Ron de Bruin Excel Programming 1 May 10th 04 07:56 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM


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