Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error trying to select a cell


Hey guys, this should be a simple one but I still havn't gotten it. The
code is he


Code:
--------------------

Public Function results() As Double

Dim answers(9, 9) As Double
Dim i, j, component As Integer


For i = 20 To 29

For j = 7 To 15

ThisWorkbook.Worksheets("Calculations").Cells(i, j).Activate
component = ThisWorkbook.Worksheets("Calculations").Cells(Acti veCell.row, 6).Value

Select Case component
Case 1
answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
Case 2
answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
Case Else
answers(i, j) = conversion(i, j)
End Select
Next j

Next i

End Function

--------------------


Conversion, Flush and Additive are all seperate functions being called
to from here. The error is in this line:


Code:
--------------------

ThisWorkbook.Worksheets("Calculations").Cells(i, j).Select

--------------------


It returns a select range error on this line implying that it is not
properly addressed.

Thanks.

~Jason


--
jclark419
------------------------------------------------------------------------
jclark419's Profile: http://www.excelforum.com/member.php...o&userid=25430
View this thread: http://www.excelforum.com/showthread...hreadid=392200

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error trying to select a cell

If you use the function in a cell like the SUM function as an example, then
you should not attempt to do any activating or selection.

If you just call this from VBA, then the sheet calculations must be the
active sheet to successfully execute that command. Otherwise it should be

ThisWorkbook.Activate
Worksheets("Calculations").Activate
For i = 20 To 29

For j = 7 To 15

ThisWorkbook.Worksheets("Calculations").Cells(i, j).Select
component = ThisWorkbook.Worksheets("Calculations").Cells(Acti veCell.row,
6).Value

Select Case component
Case 1
answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
Case 2
answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
Case Else
answers(i, j) = conversion(i, j)
End Select
Next j

Next i

--
Regards,
Tom Ogilvy


"jclark419" wrote
in message ...

Hey guys, this should be a simple one but I still havn't gotten it. The
code is he


Code:
--------------------

Public Function results() As Double

Dim answers(9, 9) As Double
Dim i, j, component As Integer


For i = 20 To 29

For j = 7 To 15

ThisWorkbook.Worksheets("Calculations").Cells(i, j).Activate
component =

ThisWorkbook.Worksheets("Calculations").Cells(Acti veCell.row, 6).Value

Select Case component
Case 1
answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
Case 2
answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
Case Else
answers(i, j) = conversion(i, j)
End Select
Next j

Next i

End Function

--------------------


Conversion, Flush and Additive are all seperate functions being called
to from here. The error is in this line:


Code:
--------------------

ThisWorkbook.Worksheets("Calculations").Cells(i, j).Select

--------------------


It returns a select range error on this line implying that it is not
properly addressed.

Thanks.

~Jason


--
jclark419
------------------------------------------------------------------------
jclark419's Profile:

http://www.excelforum.com/member.php...o&userid=25430
View this thread: http://www.excelforum.com/showthread...hreadid=392200



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error trying to select a cell


That took care of it.
Thanks for your help.

~Jaso

--
jclark41
-----------------------------------------------------------------------
jclark419's Profile: http://www.excelforum.com/member.php...fo&userid=2543
View this thread: http://www.excelforum.com/showthread.php?threadid=39220

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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error -[::::Shamran::::]- Excel Programming 7 June 7th 05 02:14 PM
Error on select statement SHIPP Excel Programming 4 March 3rd 05 08:29 PM
Range Select Error sailingdan Excel Programming 1 June 14th 04 04:24 PM


All times are GMT +1. The time now is 10:55 AM.

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"