DIM is what i am

  • Thread starter Thread starter mushy_peas
  • Start date Start date
M

mushy_peas

Say i have

Dim Current
Dim Last

and i had a cell with a number, how do i set Current to be equal tha
that value. isnt it:-

Current = Range("H1")

or am i just being a noob

Thank
 
If your "H1" is on the ActiveSheet, yes. But it's always better to
explicitly indicate which sheet.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel
 
well i used
Sheets("Till").Select
so i was on the right sheet. but it doesn work
:O
 
Try this

Dim last as integer, next as integer

Sub findRow()

last = application.worksheetfunction.counta(RAnge("A:A"))
next= last + 1
and the rest of your code here..
End sub

Regards
Peter
 
Sub Testcurrent()
Dim current as variant, current1 as Variant
Dim rng a range
set rng = worksheets("Till").Range("H1")
current = worksheets("Till").Range("H1").Value
current1 = rng.Value
msgbox Current & " - " & Worksheets("Till").Range("H1").value & _
vbNewline & Current1 & " - " & rng.Value & vbNewline & _
rng.Address(external:=True)

End sub
 
i dont get this bit
application.worksheetfunction.counta(RAnge("A:A"))
could you pls explain, ta
 
It will tell you how many cells in column A are not empty. (it counts how
many are no empty - it is using the excel worksheet function COUNTA as in

=COUNTA(A:A)
 
Thank You, Thank You!

Dim rng a range
set rng = worksheets("Till").Range("H1")
current = worksheets("Till").Range("H1").Value

It all works fine now. but why do i need "set rng
worksheets("Till").Range("H1")"

and can you just have "rng = worksheets("Till").Range("H1")". wots th
dif
 
Demonstrating several concepts for you. Use what you need.

it is sometime useful (less typing) to set a range reference (a variable
that holds a reference to a range object) to a cell or range. then you can
use this variable. this is especially true if you are working between two
workbooks.
 
Back
Top