ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting data from a worksheet (https://www.excelbanter.com/excel-programming/426764-re-getting-data-worksheet.html)

Barb Reinhardt

Getting data from a worksheet
 
Sure you can.

Trythis

Dim myWS as Excel.Worksheet

Set myWS =Worksheets("Data")

Anyplace where you are referencing a range object on the Data sheet, use this

myWS.Range ...

HTH,
Barb Reinhardt

"donwb" wrote:

Is there any way of getting data from a WorkSheet
without actually selecting it.
an extract of my code is:-

Worksheets("Data").Activate
Dim MyArray(40, 40)
For i = 2 To Cells(Cells.Rows.Count, "A").End(xlUp).Row - 1
X = Range("A" & i).Value

If Mid(Range("C" & i), 5, 1) = "(" Then
Y = Left(Range("C" & i), 7)
GoTo Line1
End If

Y = Left(Range("C" & i), 3)

Line1:
MyArray(i - 2, 0) = X
MyArray(i - 2, 1) = Y

Next i
ListBox1.List() = MyArray

What I'm trying to avoid is the screen changing from a particular WorkSheet
to the "Data" worksheet, when the code is run
donwb








All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com