Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
C C is offline
external usenet poster
 
Posts: 61
Default Need VBA for for column addition and on condition resets to 0

I have a spreadsheet that I need to increment Column X by one when the macro
is executed. When Column x = 12 then it goes back to 0 and column w is
incremented by one.

Note: Only column x resets to 0. column W increments to infinity.

Example:

March 2009
Column W Column X
10 11

April 2009 After Calculation
Column W Column X
11 0

May 2009 After Calculation
Column W Column X
11 1

Can someone help?

Thanks in advance.
CB

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,722
Default Need VBA for for column addition and on condition resets to 0

Perhaps something like this:

Sub AddOne()
Dim xColumn As String
Dim wColumn As String
'Define cells you want to use
xColumn = "X1"
wColumn = "W1"

If Range(xColumn).Value = 11 Then
Range(xColumn).Value = 0
Range(wColumn).Value = Range(wColumn).Value + 1
Else
Range(xColumn).Value = Range(xColumn).Value + 1
End If

End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"C" wrote:

I have a spreadsheet that I need to increment Column X by one when the macro
is executed. When Column x = 12 then it goes back to 0 and column w is
incremented by one.

Note: Only column x resets to 0. column W increments to infinity.

Example:

March 2009
Column W Column X
10 11

April 2009 After Calculation
Column W Column X
11 0

May 2009 After Calculation
Column W Column X
11 1

Can someone help?

Thanks in advance.
CB

  #3   Report Post  
Posted to microsoft.public.excel.programming
C C is offline
external usenet poster
 
Posts: 61
Default Need VBA for for column addition and on condition resets to 0

Luke,

Thanks so much for the help. How do I modify this code to include X1 to
X1000 & W1 to W1000? I tried changing "X1" to "X1:X1000" and "W1" to
"W1:W1000". When I did this I got an error "Runtime error '13', type
mismatch. I am very new to VBA and am at a loss how to correct this.

Thanks for your help,
CB

"Luke M" wrote:

Perhaps something like this:

Sub AddOne()
Dim xColumn As String
Dim wColumn As String
'Define cells you want to use
xColumn = "X1"
wColumn = "W1"

If Range(xColumn).Value = 11 Then
Range(xColumn).Value = 0
Range(wColumn).Value = Range(wColumn).Value + 1
Else
Range(xColumn).Value = Range(xColumn).Value + 1
End If

End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"C" wrote:

I have a spreadsheet that I need to increment Column X by one when the macro
is executed. When Column x = 12 then it goes back to 0 and column w is
incremented by one.

Note: Only column x resets to 0. column W increments to infinity.

Example:

March 2009
Column W Column X
10 11

April 2009 After Calculation
Column W Column X
11 0

May 2009 After Calculation
Column W Column X
11 1

Can someone help?

Thanks in advance.
CB

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
complex column addition formula428 Excel Programming 3 September 14th 08 06:28 PM
column addition question D Excel Worksheet Functions 1 February 19th 06 11:50 PM
Get Addition of each Column in a sheet Ahmad Jalil Qarshi Excel Programming 1 June 6th 05 06:22 AM
Addition base on condition 68magnolia71 Excel Worksheet Functions 4 April 15th 05 08:39 PM
Amend formula to include addition condition Pat Excel Worksheet Functions 1 March 16th 05 03:36 PM


All times are GMT +1. The time now is 11:58 AM.

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"