Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Need help writing a macro to Save changes in a worksheet

I am using MSExcel 2003

I am trying to write an event macro to save the worksheet after someone
enters a number into a given cell. I have two ranges named "TotalYield" and
"Cummulative". The first is a range of 4 merged cells, the second is a range
of single cells.

So far I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(Target, Me.Range("TotalYield")) Is Nothing
Then

ActiveWorkbook.save

End If

End Sub

But the problem is that the worksheet is saved when the range is selected,
not after an entry is made.

Once I have this working for the TotalYield range, I need to do the same for
the Cummulative range.

Any help would be great. Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Need help writing a macro to Save changes in a worksheet

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Me.Range("A1")) Is Nothing Then

ActiveWorkbook.Save

End If
End Sub

"TomK76" wrote:

I am using MSExcel 2003

I am trying to write an event macro to save the worksheet after someone
enters a number into a given cell. I have two ranges named "TotalYield" and
"Cummulative". The first is a range of 4 merged cells, the second is a range
of single cells.

So far I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(Target, Me.Range("TotalYield")) Is Nothing
Then

ActiveWorkbook.save

End If

End Sub

But the problem is that the worksheet is saved when the range is selected,
not after an entry is made.

Once I have this working for the TotalYield range, I need to do the same for
the Cummulative range.

Any help would be great. Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Need help writing a macro to Save changes in a worksheet

Mike,

Replacing "TotalYield" with "A1" as you suggested had no effect.

"Mike" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Me.Range("A1")) Is Nothing Then

ActiveWorkbook.Save

End If
End Sub

"TomK76" wrote:

I am using MSExcel 2003

I am trying to write an event macro to save the worksheet after someone
enters a number into a given cell. I have two ranges named "TotalYield" and
"Cummulative". The first is a range of 4 merged cells, the second is a range
of single cells.

So far I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(Target, Me.Range("TotalYield")) Is Nothing
Then

ActiveWorkbook.save

End If

End Sub

But the problem is that the worksheet is saved when the range is selected,
not after an entry is made.

Once I have this working for the TotalYield range, I need to do the same for
the Cummulative range.

Any help would be great. Thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Need help writing a macro to Save changes in a worksheet

Mike also changed the event to worksheet_change.

ps. I'd use:

me.parent.save
instead of relying on the activesheet.

TomK76 wrote:

Mike,

Replacing "TotalYield" with "A1" as you suggested had no effect.

"Mike" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Me.Range("A1")) Is Nothing Then

ActiveWorkbook.Save

End If
End Sub

"TomK76" wrote:

I am using MSExcel 2003

I am trying to write an event macro to save the worksheet after someone
enters a number into a given cell. I have two ranges named "TotalYield" and
"Cummulative". The first is a range of 4 merged cells, the second is a range
of single cells.

So far I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(Target, Me.Range("TotalYield")) Is Nothing
Then

ActiveWorkbook.save

End If

End Sub

But the problem is that the worksheet is saved when the range is selected,
not after an entry is made.

Once I have this working for the TotalYield range, I need to do the same for
the Cummulative range.

Any help would be great. Thanks!



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Need help writing a macro to Save changes in a worksheet

Dave and Mike,

I had not noticed the change in the first line. I did have to change the
"A1" to my specific named range, but it looks to be working.

Dave if you have a second, what is the advantage of using the Me.Parent.Save?

Thanks guys, I appreciate it!

"Dave Peterson" wrote:

Mike also changed the event to worksheet_change.

ps. I'd use:

me.parent.save
instead of relying on the activesheet.

TomK76 wrote:

Mike,

Replacing "TotalYield" with "A1" as you suggested had no effect.

"Mike" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Me.Range("A1")) Is Nothing Then

ActiveWorkbook.Save

End If
End Sub

"TomK76" wrote:

I am using MSExcel 2003

I am trying to write an event macro to save the worksheet after someone
enters a number into a given cell. I have two ranges named "TotalYield" and
"Cummulative". The first is a range of 4 merged cells, the second is a range
of single cells.

So far I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(Target, Me.Range("TotalYield")) Is Nothing
Then

ActiveWorkbook.save

End If

End Sub

But the problem is that the worksheet is saved when the range is selected,
not after an entry is made.

Once I have this working for the TotalYield range, I need to do the same for
the Cummulative range.

Any help would be great. Thanks!



--

Dave Peterson

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
writing a macro to save a workbook Brian Excel Worksheet Functions 2 November 20th 07 04:02 AM
Writing a macro to save worksheet Dwayne Hodges Excel Programming 1 November 17th 06 05:18 PM
Macro Save with Worksheet as file Name bbkixx Excel Programming 5 October 19th 06 05:25 PM
wRITING A mACRO TO MAKE A WORKSHEET PRINT. Glenn Excel Programming 1 April 16th 05 11:41 PM
Macro to save worksheet RSVP Excel Programming 2 April 26th 04 02:41 PM


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