Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Application.Mode

I am creating a spreadsheet that Loops through a series of continuous row,
assiging a variant variable, V(i), a specific value based on the text within
the respective cell. I then want to take the mode of all V(i) values. I
have already set up the code so it will set v(i) and tested it so I know it
works but when I try to calculate the mode I get errors.

I have tried using cells(1,1).value=application.mode(v) and
cells(1,1)=application.mode(v) but it always returns a #N/A in the cell. Is
there a different function I should be using? Below is some example of my
code:


Dim V() as variant

Select Case LCase(cell.Text)
Case "once a month"
V(i) = 0.25
Case "one time a month"
V(i) = 0.25
Case Else
If Application.CountA(cell.Resize(1, 5)) = 0 Then
V(i) = False
Else
V(i) = Application.CountA(cell.Resize(1, 5))
End If
End Select

Cells(CurrentRow + 2, CurrentColumn) = Application.Mode(V)
Cells(CurrentRow + 2, CurrentColumn).Resize(1, 5).Merge


Thanks for the Help,

Scott
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Application.Mode



if no item occurs more than once in the array
the MODE functions returns an NA# error.
(there is no most frequent occcurance)



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


sip8316 wrote :

I am creating a spreadsheet that Loops through a series of continuous
row, assiging a variant variable, V(i), a specific value based on the
text within the respective cell. I then want to take the mode of all
V(i) values. I have already set up the code so it will set v(i) and
tested it so I know it works but when I try to calculate the mode I
get errors.

I have tried using cells(1,1).value=application.mode(v) and
cells(1,1)=application.mode(v) but it always returns a #N/A in the
cell. Is there a different function I should be using? Below is
some example of my code:


Dim V() as variant

Select Case LCase(cell.Text)
Case "once a month"
V(i) = 0.25
Case "one time a month"
V(i) = 0.25
Case Else
If Application.CountA(cell.Resize(1, 5)) = 0 Then
V(i) = False
Else
V(i) = Application.CountA(cell.Resize(1, 5))
End If
End Select

Cells(CurrentRow + 2, CurrentColumn) = Application.Mode(V)
Cells(CurrentRow + 2, CurrentColumn).Resize(1, 5).Merge


Thanks for the Help,

Scott

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Application.Mode

Thanks,

But I thought of that too and checked it and there is definately a number
that is displayed significatley more times than the others. So I still don't
know what the problem is.

Scott

"keepITcool" wrote:



if no item occurs more than once in the array
the MODE functions returns an NA# error.
(there is no most frequent occcurance)



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


sip8316 wrote :

I am creating a spreadsheet that Loops through a series of continuous
row, assiging a variant variable, V(i), a specific value based on the
text within the respective cell. I then want to take the mode of all
V(i) values. I have already set up the code so it will set v(i) and
tested it so I know it works but when I try to calculate the mode I
get errors.

I have tried using cells(1,1).value=application.mode(v) and
cells(1,1)=application.mode(v) but it always returns a #N/A in the
cell. Is there a different function I should be using? Below is
some example of my code:


Dim V() as variant

Select Case LCase(cell.Text)
Case "once a month"
V(i) = 0.25
Case "one time a month"
V(i) = 0.25
Case Else
If Application.CountA(cell.Resize(1, 5)) = 0 Then
V(i) = False
Else
V(i) = Application.CountA(cell.Resize(1, 5))
End If
End Select

Cells(CurrentRow + 2, CurrentColumn) = Application.Mode(V)
Cells(CurrentRow + 2, CurrentColumn).Resize(1, 5).Merge


Thanks for the Help,

Scott


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Application.Mode


then post complete code..
I cant see you checking it in the snippet you posted.

following test works for me:
Sub TestMode()
Dim V
ReDim V(1 To 5)
V(1) = 3
V(2) = 8
V(3) = 3
V(5) = "text" 'strings are ignored
MsgBox CStr(Application.Mode(V))

V(3) = 1
MsgBox CStr(Application.Mode(V))
End Sub



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


sip8316 wrote :

Thanks,

But I thought of that too and checked it and there is definately a
number that is displayed significatley more times than the others.
So I still don't know what the problem is.

Scott

"keepITcool" wrote:



if no item occurs more than once in the array
the MODE functions returns an NA# error.
(there is no most frequent occcurance)



--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam



sip8316 wrote :

I am creating a spreadsheet that Loops through a series of
continuous row, assiging a variant variable, V(i), a specific
value based on the text within the respective cell. I then want
to take the mode of all V(i) values. I have already set up the
code so it will set v(i) and tested it so I know it works but
when I try to calculate the mode I get errors.

I have tried using cells(1,1).value=application.mode(v) and
cells(1,1)=application.mode(v) but it always returns a #N/A in the
cell. Is there a different function I should be using? Below is
some example of my code:


Dim V() as variant

Select Case LCase(cell.Text)
Case "once a month"
V(i) = 0.25
Case "one time a month"
V(i) = 0.25
Case Else
If Application.CountA(cell.Resize(1, 5)) = 0 Then
V(i) = False
Else
V(i) = Application.CountA(cell.Resize(1, 5))
End If
End Select

Cells(CurrentRow + 2, CurrentColumn) = Application.Mode(V)
Cells(CurrentRow + 2, CurrentColumn).Resize(1, 5).Merge


Thanks for the Help,

Scott


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Application.Mode

Sorry,

I checked it by having the value for V(i) displayed in the rows beneth the
actual data, then I could look at the value for v(i) and see if it coresponds
correctly to the cells I was referenceing. Heres the same code though with a
little more detail and with the loops added in.


Dim v(i) as variant
Dim CurrentColumn as Integer
Dim columnCounter as Integer
Dim rngOneColumn as Range
Dim CurrentRow as Integer


While (Cells(5, CurrentColumn) < "")
ReDim V(1 To ColumnCounter)
CurrentRow = 6
i = 6
For Each cell In rngOneColumn
Select Case LCase(cell.Text)
Case "once a month"
V(i) = 0.25
Case "one time a month"
V(i) = 0.25
Case "7 days a week"
V(i) = 7
Case Else
If Application.CountA(cell.Resize(1, 5)) = 0 Then
V(i) = False
Else
V(i) = Application.CountA(cell.Resize(1, 5))
End If

End Select
CurrentRow = CurrentRow + 1
Next
Cells(CurrentRow + 2, CurrentColumn) = Application.Mode(V)
Cells(CurrentRow + 2, CurrentColumn).Resize(1, 5).Merge
Wend


This code would loop through a given number of columns and take the mode of
the V(i) values of the all the cells in a respective column. So I will end
up with many modes, one for each column.

I checked it by adding code such as this:

Cells(VDisplayerRow, VDisplayerCol) = V(i)


In the loops I had those two variables set up so they progressed with the
rest of the calculations. In other words if I had 10 rows and 10 columns of
data, the v value of cell(1,1) was displayed in (11,1)....cell(1,2) in
(11,2)....cell(1,3) in (11,3)....and in a similar maner cell(2,1) in
(12,1).....cell(3,1) in (13,1) When I did this I checked all of the v(i)
values and they were all correct. However when I tried to uses
application.mode(V) I recieved #N/A for the mode of each column.

Thanks again,

Scott
"keepITcool" wrote:


then post complete code..
I cant see you checking it in the snippet you posted.

following test works for me:
Sub TestMode()
Dim V
ReDim V(1 To 5)
V(1) = 3
V(2) = 8
V(3) = 3
V(5) = "text" 'strings are ignored
MsgBox CStr(Application.Mode(V))

V(3) = 1
MsgBox CStr(Application.Mode(V))
End Sub



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


sip8316 wrote :

Thanks,

But I thought of that too and checked it and there is definately a
number that is displayed significatley more times than the others.
So I still don't know what the problem is.

Scott

"keepITcool" wrote:



if no item occurs more than once in the array
the MODE functions returns an NA# error.
(there is no most frequent occcurance)



--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam


sip8316 wrote :

I am creating a spreadsheet that Loops through a series of
continuous row, assiging a variant variable, V(i), a specific
value based on the text within the respective cell. I then want
to take the mode of all V(i) values. I have already set up the
code so it will set v(i) and tested it so I know it works but
when I try to calculate the mode I get errors.

I have tried using cells(1,1).value=application.mode(v) and
cells(1,1)=application.mode(v) but it always returns a #N/A in the
cell. Is there a different function I should be using? Below is
some example of my code:


Dim V() as variant

Select Case LCase(cell.Text)
Case "once a month"
V(i) = 0.25
Case "one time a month"
V(i) = 0.25
Case Else
If Application.CountA(cell.Resize(1, 5)) = 0 Then
V(i) = False
Else
V(i) = Application.CountA(cell.Resize(1, 5))
End If
End Select

Cells(CurrentRow + 2, CurrentColumn) = Application.Mode(V)
Cells(CurrentRow + 2, CurrentColumn).Resize(1, 5).Merge


Thanks for the Help,

Scott




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Application.Mode

Scott,
could you please mail your workbook?

cant figure this out from your example
but without the actual data.

my email is below.. just add the @ and the .

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


sip8316 wrote :

Sorry,

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
MODE calc where more than one mode number! Struggling in Sheffield[_2_] New Users to Excel 2 October 15th 09 04:52 PM
Combo Box goes to edit mode even if design mode is in OFF position Chas Excel Discussion (Misc queries) 0 January 7th 05 07:21 PM
coverting answer from Radian mode to degree mode Xmastrzman Excel Worksheet Functions 1 November 10th 04 04:45 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM
Enter Excel Design Mode and Exit Design Mode Bill Lunney Excel Programming 0 August 4th 03 07:48 AM


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