Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default offset question

could someone help me with this code

Private Sub Worksheet_Activate()

Dim jan As String, I As Long, X As Integer

Dim v As Variant

For I = 1 To 12
X = I
jan = "=SumProduct(--(Sheet4!A1:A30000=" & _
"OFFSET('processed Amount'!A1,0,X,1,1)),--(Sheet4!AL1:AL30000 0))"
v = Evaluate(jan)
Range(X&2) = v
Next I
End Sub

I'm trying to populate cells b2...m2 with the number of counts based on the
following criteria:
the date is equal to the dates in cells b1...m1 and the total is 0

Thanks for nay help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default offset question

Hmm...
I'm not clear on exactly what you want or which bit isn't working but
here goes.

Range(2,X+1) = v

Row reference then columnn reference. So row 2, Column X + 1.
This should give you range(2,2) throught to range(2,13)
which is columns B to M

rather than
Range(X&2) = v

the "&" character will either add the numbers together or attempt to
concatenate them into a string, I'm not sure without testing.

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default offset question

it doesn't seem like the X in the offset procedure is working correctly in
cell B2 I have the #name? error message

at the end of the code i'm trying to concantenate the X variable and row 2.

Thanks for any help

"ram" wrote:

could someone help me with this code

Private Sub Worksheet_Activate()

Dim jan As String, I As Long, X As Integer

Dim v As Variant

For I = 1 To 12
X = I
jan = "=SumProduct(--(Sheet4!A1:A30000=" & _
"OFFSET('processed Amount'!A1,0,X,1,1)),--(Sheet4!AL1:AL30000 0))"
v = Evaluate(jan)
Range(X&2) = v
Next I
End Sub

I'm trying to populate cells b2...m2 with the number of counts based on the
following criteria:
the date is equal to the dates in cells b1...m1 and the total is 0

Thanks for nay help

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default offset question

Hi Ram,

In your Offset formula you need to substitute the occurances of X that
relate to your X variable with
" & X & "
because you do not want the character X to appear, but it's value, eg
jan = "=SumProduct(--(Sheet4!A1:A30000=" & _
"OFFSET('processed Amount'!A1,0," & X & ",1,1)),--(Sheet4!AL1:AL30000
0))"

if it still doesn't work, try
" & cstr(X) & "

As for concatenating the value of X to the number 2, why? I don't think
it will work.
the Range command needs to be populated with a string, eg
Range("A5").value
I recommend using
Cells(2,X+1) = v
I was mistaken earlier when I said: Range(2,X+1) = v

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default offset question

I think "range(X&2)=v" should be "cells(2,x+1)=v" (+1 because you suggested
populating columns b:m, but X takes on the values 1 through 12).
Why not just put the sumproduct formulas on the worksheet, rather than
calculate the formula results on activation?

"ram" wrote:

it doesn't seem like the X in the offset procedure is working correctly in
cell B2 I have the #name? error message

at the end of the code i'm trying to concantenate the X variable and row 2.

Thanks for any help

"ram" wrote:

could someone help me with this code

Private Sub Worksheet_Activate()

Dim jan As String, I As Long, X As Integer

Dim v As Variant

For I = 1 To 12
X = I
jan = "=SumProduct(--(Sheet4!A1:A30000=" & _
"OFFSET('processed Amount'!A1,0,X,1,1)),--(Sheet4!AL1:AL30000 0))"
v = Evaluate(jan)
Range(X&2) = v
Next I
End Sub

I'm trying to populate cells b2...m2 with the number of counts based on the
following criteria:
the date is equal to the dates in cells b1...m1 and the total is 0

Thanks for nay help



  #6   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default offset question

thanks forthe response

I changed the range(x&2)=v to cells(2,x=1)=v and now cells b2...m2 are
populated, however they all have the #name? error. Do you know why that would
happen?

is it because the word offset is in the wrong place?


Thanks for any help

"bpeltzer" wrote:

I think "range(X&2)=v" should be "cells(2,x+1)=v" (+1 because you suggested
populating columns b:m, but X takes on the values 1 through 12).
Why not just put the sumproduct formulas on the worksheet, rather than
calculate the formula results on activation?

"ram" wrote:

it doesn't seem like the X in the offset procedure is working correctly in
cell B2 I have the #name? error message

at the end of the code i'm trying to concantenate the X variable and row 2.

Thanks for any help

"ram" wrote:

could someone help me with this code

Private Sub Worksheet_Activate()

Dim jan As String, I As Long, X As Integer

Dim v As Variant

For I = 1 To 12
X = I
jan = "=SumProduct(--(Sheet4!A1:A30000=" & _
"OFFSET('processed Amount'!A1,0,X,1,1)),--(Sheet4!AL1:AL30000 0))"
v = Evaluate(jan)
Range(X&2) = v
Next I
End Sub

I'm trying to populate cells b2...m2 with the number of counts based on the
following criteria:
the date is equal to the dates in cells b1...m1 and the total is 0

Thanks for nay help

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default offset question

Thanks for all your help

my code is now working correctly


bpeltzer wrote:
I think "range(X&2)=v" should be "cells(2,x+1)=v" (+1 because you suggested
populating columns b:m, but X takes on the values 1 through 12).
Why not just put the sumproduct formulas on the worksheet, rather than
calculate the formula results on activation?

"ram" wrote:

it doesn't seem like the X in the offset procedure is working correctly in
cell B2 I have the #name? error message

at the end of the code i'm trying to concantenate the X variable and row 2.

Thanks for any help

"ram" wrote:

could someone help me with this code

Private Sub Worksheet_Activate()

Dim jan As String, I As Long, X As Integer

Dim v As Variant

For I = 1 To 12
X = I
jan = "=SumProduct(--(Sheet4!A1:A30000=" & _
"OFFSET('processed Amount'!A1,0,X,1,1)),--(Sheet4!AL1:AL30000 0))"
v = Evaluate(jan)
Range(X&2) = v
Next I
End Sub

I'm trying to populate cells b2...m2 with the number of counts based on the
following criteria:
the date is equal to the dates in cells b1...m1 and the total is 0

Thanks for nay help


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
Offset Question Barb Reinhardt Excel Worksheet Functions 1 September 19th 06 02:49 PM
Offset question Chris Excel Worksheet Functions 2 August 9th 06 08:59 PM
OFFSET() question for '97 Adam Kroger Excel Discussion (Misc queries) 2 December 11th 05 03:04 PM
Offset question Patrick Simonds Excel Programming 1 January 19th 05 06:33 AM
An OFFSET question johnb Excel Worksheet Functions 2 December 7th 04 04:56 PM


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