Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't set value in integer

Status
Not open for further replies.

y2k1981

Programmer
Aug 2, 2002
773
IE
please somebody help me, this is driving me daft. the following is part of my code:
Code:
dim start as integer

set start = val(cn + 1)
cn is another variable that is declared and populated successfully (by looping through a set of excel cells) earlier in the program. All I want to do is set the variable start to be one value higher than cn. but everytime I try to run this it says object required and "start =" is selected. please ... anybody? I've also tried set start = cn +1 but no good either.
 
CN is set as a range, here are examples of how to do what you require.

'this will select the cell to the right of dates
Set st = Range(cn).Offset(0, 1)
st.Activate

' this will select the cell to the left of dates.
Set st = Range(cn).Offset(0, -1)
st.Activate

'this will select the cell above dates
Set st = Range(cn).Offset(-1, 0)
st.Activate
' this will select the cell below dates
Set st = Range(cn).Offset(1, 0)
st.Activate

also use :-
Dim st As Range

is this what you are looking for.

Rob.


Thanks Rob.[yoda]
 
...TRY THIS ONE


set start = val((INT(cn+0.5*1)/1) + 1)
 
actually Rob, no, cn isn't a range, it's also an integer. I eventually got this to work by simply removing the set keywork and saying start = val(cn + 1)

ETID, not exactly sure what you're one does, is it just a compliated way of adding one to the variable cn?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top