Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default turninf off macros

Hi,

I have this code written which doesnt let the user to select the cell
(to prevent accidental deletion):

1st macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Me.Range("b2:c2001")) Is Nothing Then Exit Sub
Me.Cells(Target.Row, "D").Select

End Sub


Now the problem is that i want a macro which will just copy the b and
columns and paste the values to the same columns, the macro is preet
simple, the problem is that because of the earlier macro, i canno
select the columns.....

2nd Macro:
Sub Macro()

Range("B1:C1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("B1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False
End Sub


is there a way where i can turn the fist macro OFF when the secon
macro runs???

thanks for any help!!

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default turninf off macros

No need to select the cells to change then, just use this
Range("B1:C2001") = Range("B1:C2001").Value

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 97 & 2000
** remove news from my email address to reply by email **

"paritoshmehta " wrote in
message ...
Hi,

I have this code written which doesnt let the user to select the cells
(to prevent accidental deletion):

1st macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Me.Range("b2:c2001")) Is Nothing Then Exit Sub
Me.Cells(Target.Row, "D").Select

End Sub


Now the problem is that i want a macro which will just copy the b and c
columns and paste the values to the same columns, the macro is preety
simple, the problem is that because of the earlier macro, i cannot
select the columns.....

2nd Macro:
Sub Macro()

Range("B1:C1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("B1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
End Sub


is there a way where i can turn the fist macro OFF when the second
macro runs???

thanks for any help!!!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default turninf off macros

one suggestion is to declare a public variable as a boolean then you can set it in the copying macro and test it in this one

In Module
Dim Public LetCopy as Boolea

In Copy macro
Private Sub MyCopyMacro(
LetCopy = Tru
Do your code here..

LetCopy= Fals
End Su

Private Sub Worksheet_SelectionChange(ByVal Target As Range
if LetCopy = True Then Exit Su
If Intersect(Target, Me.Range("b2:c2001")) Is Nothing Then Exit Su
if Target.Cells.Count 1 Then Exit Su
Me.Cells(Target.Row, "D").Selec

End Su

----- paritoshmehta wrote: ----

Hi

I have this code written which doesnt let the user to select the cell
(to prevent accidental deletion)

1st macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range
If Intersect(Target, Me.Range("b2:c2001")) Is Nothing Then Exit Su
Me.Cells(Target.Row, "D").Selec

End Su


Now the problem is that i want a macro which will just copy the b and
columns and paste the values to the same columns, the macro is preet
simple, the problem is that because of the earlier macro, i canno
select the columns.....

2nd Macro:
Sub Macro(

Range("B1:C1").Selec
Range(Selection, Selection.End(xlDown)).Selec
Selection.Cop
Range("B1").Selec
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:=
False, Transpose:=Fals
End Su


is there a way where i can turn the fist macro OFF when the secon
macro runs??

thanks for any help!!


--
Message posted from http://www.ExcelForum.com


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default turninf off macros

please help me
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
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Excel Programming 5 September 24th 03 03:10 AM


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