![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 6
|
I would like to retrieve some data in a workbook using a macro without going to that sheet, is there a simple way to do this?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
Here's a couple of methods for you
Code:
Public Sub GetValue()
CellValue = Sheets("Sheet1").Cells(1, 1).Value 'method one
MsgBox (CellValue)
CellValue = ActiveSheet.Cells(1, 1).Value 'method two
MsgBox (CellValue)
CellValue = Sheets("Sheet1").Range("A1").Value ' method 3
MsgBox (CellValue)
With Sheets("Sheet1").Cells(1, 1) ' method 4
CellValue = .Value
End With
MsgBox (CellValue)
End Sub
[ This Message was edited by: Nimrod on 2002-05-20 12:39 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|