Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default macro runs except from function


I have a macro that copy pastes rows. This works fine if I
run it from the Run Macro inside excel.
I tried to make a function and call it from the function,
but it does nothing? It steps through but changes nothing
on the sheet. It is like it can't find the sheet

cell has formula
=check4diff(B6,B5)


Function check4diff(Old_Value, New_Value)

If Old_Value=New_Value Then
check4diff=1
Else
Application.Run("insertrowandcopy")
' I also tried the Call syntax and it was no different
check4diff=2
End If

End Function

Sub insertrowandcopy()

Worksheets("Sheet1").Activate
Worksheets("Sheet1").Rows(5).Copy
Worksheets("Sheet1").Rows(7).Select
Selection.Insert Shift:=xlDown

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro runs except from function


"Brenda" wrote in message
...

I have a macro that copy pastes rows. This works fine if I
run it from the Run Macro inside excel.
I tried to make a function and call it from the function,
but it does nothing? It steps through but changes nothing
on the sheet. It is like it can't find the sheet

cell has formula
=check4diff(B6,B5)


Function check4diff(Old_Value, New_Value)

If Old_Value=New_Value Then
check4diff=1
Else
Application.Run("insertrowandcopy")
' I also tried the Call syntax and it was no different
check4diff=2
End If

End Function

Sub insertrowandcopy()

Worksheets("Sheet1").Activate
Worksheets("Sheet1").Rows(5).Copy
Worksheets("Sheet1").Rows(7).Select
Selection.Insert Shift:=xlDown

End Sub


"It steps through but changes nothing on the sheet" because worksheet
functions are not allowed to change anything in any worksheet.


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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Why macro runs on the same sheet? Harshad[_2_] Excel Discussion (Misc queries) 1 September 15th 08 09:39 AM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Which Macro Runs...? Bill Martin Excel Discussion (Misc queries) 7 September 29th 05 12:42 PM
Macro Runs if Template name is ..... Nigel Downing Excel Programming 5 December 19th 03 03:49 AM


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