Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Macro Help with Variable

I calculate my variable counter by counting the number of rows in the
previous worksheet. The value ends up being 107, which is correct.

The problem I have is that I have to later functions I want to use that have
a varying number of rows and I want use the counter variable as the row
number. Basically, I want the statement below to work, except replacing the
107 with counter.

'First Shift Failure Data
x = 2
Do While Cells(x, 1).Value < ""
Cells(x, 5).Value =
"=SUMPRODUCT(--(Data!R3C[4]:R[107]C[4]=""FIRST""),--(Data!R3C[5]:R[107]C[5]=RC1))"
x = x + 1
Loop

Any help is appreciated

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Macro Help with Variable

assuming "counter" is the name of your variable, try changing your formula to
this
"=SUMPRODUCT(--(Data!R3C[4]:R[" & counter &
"]C[4]=""FIRST""),--(Data!R3C[5]:R[" & counter & "]C[5]=RC1))"

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Ben" wrote:

I calculate my variable counter by counting the number of rows in the
previous worksheet. The value ends up being 107, which is correct.

The problem I have is that I have to later functions I want to use that have
a varying number of rows and I want use the counter variable as the row
number. Basically, I want the statement below to work, except replacing the
107 with counter.

'First Shift Failure Data
x = 2
Do While Cells(x, 1).Value < ""
Cells(x, 5).Value =
"=SUMPRODUCT(--(Data!R3C[4]:R[107]C[4]=""FIRST""),--(Data!R3C[5]:R[107]C[5]=RC1))"
x = x + 1
Loop

Any help is appreciated

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
Macro prompts for a number to be used in this macro as a variable Drahos Excel Programming 6 May 31st 06 10:26 AM
Running a variable macro when any value is entered into a variable cell [email protected] Excel Programming 3 December 14th 05 05:15 PM
Macro Creating Variable and using variable in a SQL statement Jimmy Excel Programming 4 October 25th 04 02:36 AM
using one macro to set a variable in another Tim[_39_] Excel Programming 2 July 14th 04 01:42 PM
Variable Macro Ronbo Excel Programming 3 June 24th 04 01:53 AM


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