getting values without using "select"

O

ornit

hello all
I have a question:
I'm trying to use values from different worksheets but I don't know ho
to do it without using the "select" command, I don't even know if it'
possible.

Here is an example:

Sheets("january").Select
Range("A12").Select
Selection.copy

Can I get the value without "selecting" it first?

thank
 
C

Chip Pearson

It is almost always unnecessary to Select a range before using
it. For example,

Dim Var As Variant
Var = Worksheets("January").Range("A12").Value
' or
Worksheets("January").Range("A12").Copy


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
T

Tom Ogilvy

Sheets("January").Range("A12").Copy _
Destination:=Sheets("February").Range("M9")
 
G

Gord Dibben

ornit

Range(Range("A1"), Range("A1").End(xlDown)).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.Paste

is equal to.....

Range(Range("A1"), Range("A1").End(xlDown)).Copy _
Destination:=Sheets("Sheet2").Range("A1")

Instead of......

Dim actSht As Worksheet
Set actSht = ActiveSheet
Worksheets("Sheet2").Activate
Range("A1:J10").Select
Selection.Copy
actSht.Activate
Range("K43").Select
ActiveSheet.Paste

use.......

Worksheets("Sheet2").Range("A1:J10").Copy _
Destination:=ActiveSheet.Range("K43")

or, if you just want to copy values:

Range("K43").Resize(10, 10).Value = _
Worksheets("Sheet2").Range("A1:J10").Value

which bypasses using the Clipboard (and is analogous to Paste
Special/Values)

Gord Dibben Excel MVP
 
Top