Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Modify code from one macro to another...any takers?

Help. How can this code be modified....


----------------------------------------------
Sub sched()
Dim a1 As Boolean, a2 As Boolean, n As Long

For n = 2 To 35001
a1 = False
a2 = False

If 20030905 = Cells(n, 7).Value Then
If 20030905 = Cells(n, 8).Value Then
If Mid(Cells(n, 9).Value, 5, 1) = "Y" Then a1 = True
End If
End If

If (Cells(n, 1).Value = "DTW") Or _
(Cells(n, 1).Value = "MEM") Or _
(Cells(n, 1).Value = "MSP") Or _
(Cells(n, 3).Value = "DTW") Or _
(Cells(n, 3).Value = "MEM") Or _
(Cells(n, 3).Value = "MSP") _
Then
If Not (Cells(n, 5).Value = "CO") Then a2 = True
Else
If Not (Cells(n, 5).Value = "NW") Then a2 = True
End If

If (a1 And a2) Then
Cells(n, 11).Value = 1
Else
Cells(n, 11).Value = 0
End If
Next
End Sub

-----------------------------------------------------------

To match this...............

Function schedulecleanup(rowNum As Long) As Integer
If Cells(rowNum, 7).Value 20030905 Or _
Cells(rowNum, 8).Value < 20030905 Or _
UCase(Mid(Cells(rowNum, 9).Value, 5, 1)) < "Y" Then
schedulecleanup = 0
Exit Function
End If

Select Case UCase(Cells(rowNum, 5).Value)
Case "NW"
Select Case UCase(Cells(rowNum, 1))
Case "DTW", "MEM", "MSP" 'condition 1
schedulecleanup = 1
Case Else
Select Case UCase(Cells(rowNum, 3))
Case "DTW", "MEM", "MSP" 'condition 1
schedulecleanup = 1
Case Else 'condition 2
schedulecleanup = 0
End Select
End Select
Case "CO"
Select Case UCase(Cells(rowNum, 1))
Case "DTW", "MEM", "MSP" 'condition 3
schedulecleanup = 0
Case Else
Select Case UCase(Cells(rowNum, 3))
Case "DTW", "MEM", "MSP" 'condition 3
schedulecleanup = 0
Case Else 'condition 4
schedulecleanup = 1
End Select
End Select
Case Else 'condition 5
schedulecleanup = 1
End Select
End Function


Sub cleanuptime()
For x = 2 To 30001
Cells(x, 12).Value = schedulecleanup(x)
Next
End Sub

----------------------------------------------------

Please help.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Modify code from one macro to another...any takers?

Copy the one and paste over the other?

What would constitute a match in your opinion?

In article ,
coventry england wrote:

Help. How can this code be modified....

<snip

To match this...............

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Modify code from one macro to another...any takers?

I want to use the macro and not the function. The first set of code is
designed as a function and second is a macro. A macro is what I would
like. So is it possible?

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Modify code from one macro to another...any takers?

Your first set of code is declared as

Sub sched()


your second as

Function schedulecleanup(rowNum As Long) As Integer


Yet below you describe just the opposite, so it is unclear what you want.

--
Regards,
Tom Ogilvy

coventry england wrote in message
...
I want to use the macro and not the function. The first set of code is
designed as a function and second is a macro. A macro is what I would
like. So is it possible?

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Modify code from one macro to another...any takers?

Perhaps I was unclear. The one with the sub is what I would like to
modify to do what the function does - that was my original intent.
However, I may have confused you. Basically, I want to use a macro and
not a function, whatever it takes. Hope Im clearer this time. The
fuction is what works well with what I need. The macro (sub) code I
published is useless (it was worthwhile at one point, but no longer).
Appreciate your help.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Modify code from one macro to another...any takers?

Id like to clarify again: I want to convert the function to a macro
because the result of the function is acceptable. I want a macro to do
the job that the function performs. Anything to clarify my point. Thanks
a million.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default Modify code from one macro to another...any takers?


Don't see why you need to modify the code that's already there.
If the function does what is required for a single row, just run Sub
cleanuptime which does it for 30000 rows.


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Modify code from one macro to another...any takers?

Thats the point I guess. I dont want to use a formula at all. Just a
macro I can click? Please let me know.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default Modify code from one macro to another...any takers?

Coventry england wrote:
Thats the point I guess. I dont want to use a formula at all. Just a
macro I can click? Please let me know.

But you've got one in the code you posted, right after the Function
definition. It's
Sub cleanuptime

I don't see what problem you have in using it?


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Modify code from one macro to another...any takers?

Bill - When i tried to run the macro, it gave me an error. Thats why I
am confused myself.
Could you help me?
Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default Modify code from one macro to another...any takers?

Coventry england wrote:
When i tried to run the macro, it gave me an error.

#What error did it give you?
On which line was the error?

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

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
Modify code bigmaas Excel Discussion (Misc queries) 2 February 16th 10 10:51 AM
Modify Code Richard Excel Worksheet Functions 0 March 13th 08 08:19 PM
Modify Macro Code Depending on Excel Version John Taylor Excel Discussion (Misc queries) 11 February 26th 07 04:19 AM
No Takers- Vlookup reno Excel Discussion (Misc queries) 6 June 29th 06 12:51 AM
Need HELP to modify code (need more automation) Paul B[_6_] Excel Programming 6 July 12th 03 10:08 AM


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