Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Starting a Macro where the cursor is

I recorded a macro to chart a range of data. But since the data can be
at any cell in the worksheet, I would like to generalize the macro by
telling it to start at the cell where the cursor happens to be.....I
would appreciate it if someone can tell me the code to do that

Tayseer

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Starting a Macro where the cursor is

You could use Selection.[do something] or ActiveCell.[do something]
but I would give it some serious thought before doing either. Maybe a
Workbook_Open event or a Worksheet_Change event would be a better approach.

" wrote:

I recorded a macro to chart a range of data. But since the data can be
at any cell in the worksheet, I would like to generalize the macro by
telling it to start at the cell where the cursor happens to be.....I
would appreciate it if someone can tell me the code to do that

Tayseer


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Starting a Macro where the cursor is

Hi Tayseer, after reading your post again, I think using the Selection.[do
something] approach would work. Disregard my suggestions about the
Workbook_Open and Worksheet_Change events. I had read your post as needing
something to trigger the macro instead of designating the starting point.
However, it is advisable to minimize the use of the Selection method as much
a possible. The code runs more efficiently if you use code that gives direct
instruction like
Sheet(1).Range("B5").[do something]

" wrote:

I recorded a macro to chart a range of data. But since the data can be
at any cell in the worksheet, I would like to generalize the macro by
telling it to start at the cell where the cursor happens to be.....I
would appreciate it if someone can tell me the code to do that

Tayseer


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Starting a Macro where the cursor is

On Nov 3, 6:34 am, JLGWhiz wrote:
Hi Tayseer, after reading your post again, I think using the Selection.[do
something] approach would work. Disregard my suggestions about the
Workbook_Open and Worksheet_Change events. I had read your post as needing
something to trigger the macro instead of designating the starting point.
However, it is advisable to minimize the use of the Selection method as much
a possible. The code runs more efficiently if you use code that gives direct
instruction like
Sheet(1).Range("B5").[do something]



" wrote:
I recorded a macro to chart a range of data. But since the data can be
at any cell in the worksheet, I would like to generalize the macro by
telling it to start at the cell where the cursor happens to be.....I
would appreciate it if someone can tell me the code to do that


Tayseer- Hide quoted text -


- Show quoted text -


Thanx so much..I'll try it

Tayseer

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Starting a Macro where the cursor is

On Nov 3, 5:34 am, JLGWhiz wrote:
Hi Tayseer, after reading your post again, I think using the Selection.[do
something] approach would work. Disregard my suggestions about the
Workbook_Open and Worksheet_Change events. I had read your post as needing
something to trigger the macro instead of designating the starting point.
However, it is advisable to minimize the use of the Selection method as much
a possible. The code runs more efficiently if you use code that gives direct
instruction like
Sheet(1).Range("B5").[do something]



" wrote:
I recorded a macro to chart a range of data. But since the data can be
at any cell in the worksheet, I would like to generalize the macro by
telling it to start at the cell where the cursor happens to be.....I
would appreciate it if someone can tell me the code to do that


Tayseer- Hide quoted text -


- Show quoted text -


Sorry to bother you, but I am new to VBA. Here is the code that I
currently have:

Sub chart_test()
ActiveCell.CurrentRegion.Select
Set tbl = ActiveCell.CurrentRegion
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=tbl
End Sub

Thanx for all the help

Tayseer

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
starting macro again Davidm Excel Discussion (Misc queries) 3 June 3rd 09 04:12 AM
Starting macro Davidm Excel Discussion (Misc queries) 3 June 3rd 09 04:09 AM
Starting a macro execution where the cursor happens to be [email protected] Charts and Charting in Excel 1 November 4th 07 07:16 AM
Starting A Macro zephyr Excel Discussion (Misc queries) 2 November 10th 06 12:03 PM
Macro not starting Larry[_12_] Excel Programming 1 January 15th 04 04:52 PM


All times are GMT +1. The time now is 05:22 PM.

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"