Range Selection


Posted by Barry Ward on August 09, 2001 4:46 AM

I have a macro that currently runs on data in a specific location. How can I get the macro to run on the data that is currently selected?

Posted by Joe Was on August 09, 2001 5:29 AM

Easy, Change the object (First part of the statement before the command period) to the word Selection.

Posted by Barry Ward on August 09, 2001 6:52 AM

Doh!


Posted by Joe Was on August 09, 2001 7:27 AM

I don't know what " Doh!" means, but if you want some code, here:


'If the user clicks cell B5 a redirect takes them to a defined range for data input.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$5" Then
Application.Undo
Range("MyInput").Select
End If

What ever is inputed into "MyInput" is used to autofill the range below.

Selection.AutoFill Destination:=Worksheets("Sheet1").Range("A1:A20")

Hope this helps, If you post your code you could save everyone a lot of time! If everyone was a mind reader we would not need this B bord. JSW


End Sub




Posted by Mark W. on August 09, 2001 7:37 AM

Welcome to the world of Homer Simpson