Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MaR MaR is offline
external usenet poster
 
Posts: 17
Default Basic programming help

Code:
Function getsask(ByVal SaskNr As Integer, ByVal Target As Range)
Dim a As Integer
a = Target.Offset(1, 0).Value

getsask = a
End Function

When I do =getsask(1, A1:A2) i get #VALUE!

Any ideas how to correctly get Integer from cell?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Basic programming help

What do you expect the value of Range("A1:A2").Offset(1, 0).Value to be ?
Will these values fit into a single integer ?

So
You need to check that Target is a single cell or take the .Value of the
first cell in the range.
Also, what if the .Value is not an integer ?

NickHK

"MaR" wrote in message
...
Code:
Function getsask(ByVal SaskNr As Integer, ByVal Target As Range)
Dim a As Integer
a = Target.Offset(1, 0).Value

getsask = a
End Function

When I do =getsask(1, A1:A2) i get #VALUE!

Any ideas how to correctly get Integer from cell?



  #3   Report Post  
Posted to microsoft.public.excel.programming
MaR MaR is offline
external usenet poster
 
Posts: 17
Default Basic programming help

What I'm doing is I'm trying to go through whole cells in range and check
them by Value

"NickHK" rašė:

What do you expect the value of Range("A1:A2").Offset(1, 0).Value to be ?
Will these values fit into a single integer ?

So
You need to check that Target is a single cell or take the .Value of the
first cell in the range.
Also, what if the .Value is not an integer ?

NickHK

"MaR" wrote in message
...
Code:
Function getsask(ByVal SaskNr As Integer, ByVal Target As Range)
Dim a As Integer
a = Target.Offset(1, 0).Value

getsask = a
End Function

When I do =getsask(1, A1:A2) i get #VALUE!

Any ideas how to correctly get Integer from cell?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Basic programming help

Yes, but you are passing A1:A2 as the range.
so multiple values cannot be put in a single Integer

This will work, assuming Range("A1").Offset(1,) contains a number in the
range -32,768 to 32,767.
=getsask(1, A1)

Or this
=getsask(1, A1:A2)
if you change the function:
Public Function GetSask(SaskNr As Integer, Target As Range) As Integer
Dim a As Integer
a = Target.Offset(1, 0).Range("A1").Value
GetSask = a
End Function

Also, what is the purpose of SaskNr, as it is not used ?

NickHK

"MaR" wrote in message
...
What I'm doing is I'm trying to go through whole cells in range and check
them by Value

"NickHK" rase:

What do you expect the value of Range("A1:A2").Offset(1, 0).Value to be

?
Will these values fit into a single integer ?

So
You need to check that Target is a single cell or take the .Value of the
first cell in the range.
Also, what if the .Value is not an integer ?

NickHK

"MaR" wrote in message
...
Code:
Function getsask(ByVal SaskNr As Integer, ByVal Target As Range)
Dim a As Integer
a = Target.Offset(1, 0).Value

getsask = a
End Function

When I do =getsask(1, A1:A2) i get #VALUE!

Any ideas how to correctly get Integer from cell?






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
Visual Basic Programming for Excel Venkatesh New Users to Excel 4 August 6th 07 11:48 AM
Visual Basic programming Jannick Excel Discussion (Misc queries) 2 February 27th 06 02:23 PM
Help with Visual Basic programming phoenixx153 Excel Programming 2 February 27th 06 01:52 AM
Help! complicated programming visual basic Lisa Excel Programming 2 February 19th 06 06:23 PM
v.basic misc programming ? mark kubicki Excel Programming 6 February 5th 04 05:06 PM


All times are GMT +1. The time now is 05:45 PM.

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"