#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Coding

What would be the correct code for the following macro:

Sub Calc()
If [B13] < [D3] + 1 Then [D13] = [D5] + 1
End If
If [B13] [D3] Then [D13] = [D5]
End If
If [B13] = 0 Then [D13] = [D5]
End If
End Sub

All cells are numeric values 0 up


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default Coding

On Sun, 10 Jul 2011 16:18:40 -0700 (PDT), " wrote:

What would be the correct code for the following macro:

Sub Calc()
If [B13] < [D3] + 1 Then [D13] = [D5] + 1
End If
If [B13] [D3] Then [D13] = [D5]
End If
If [B13] = 0 Then [D13] = [D5]
End If
End Sub

All cells are numeric values 0 up


Perhaps:

Select Case [b13]
Case Is < [d3] + 1
[d13] = [d5] + 1
Case Is = 0 Or [d5]
[d13] = [d5]
End Select

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Coding

What would be the correct code for the following macro:

Sub Calc()
If [B13] < [D3] + 1 Then [D13] = [D5] + 1
End If
If [B13] [D3] Then [D13] = [D5]
End If
If [B13] = 0 Then [D13] = [D5]
End If
End Sub

All cells are numeric values 0 up


What about if [B13] = [D3]? Or was that what you meant to type for your last
If..Then statement? Assuming that is what you meant, try this...

[D13] = [D5] - ([B13] < [D3] + 1)

Rick Rothstein (MVP - Excel)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Coding

What would be the correct code for the following macro:

Sub Calc()
If [B13] < [D3] + 1 Then [D13] = [D5] + 1
End If
If [B13] [D3] Then [D13] = [D5]
End If
If [B13] = 0 Then [D13] = [D5]
End If
End Sub

All cells are numeric values 0 up


What about if [B13] = [D3]? Or was that what you meant to type for your
last If..Then statement? Assuming that is what you meant, try this...

[D13] = [D5] - ([B13] < [D3] + 1)


Actually, in looking at what you wrote more carefully, I think you might
actually want this (I'm assuming your numbers are always whole numbers)...

[D13] = [D5] - (([B13] < [D3] + 1) And ([B13] < 0))

Rick Rothstein (MVP - Excel)

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
Help on coding please? Eric Excel Programming 3 April 18th 08 09:53 AM
Help on coding please Eric Excel Programming 4 March 20th 08 04:21 PM
Can this be done with coding? Dan the Man[_2_] Excel Programming 4 August 10th 07 08:18 PM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM


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