Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Where is My Data

In the following code the ActiveCell is always empty.

If the computer reads the WorkBook, where is the data in memory?

Option Explicit
Sub TestIntl()

Dim wkst As Worksheet
Dim wslb As Worksheet
Dim lastRow As Long

lastRow = Range("L" & Rows.Count).End(xlUp).Row
Range("L1").Select

Set wkst = ActiveSheet
Do Until ActiveCell.Row lastRow
MsgBox ActiveCell.Value ' Always Empty
ActiveCell.Offset(1, 0).Activate ' Move to Next Row
Loop

lastRow = Range("L" & Rows.Count).End(xlUp).Row
Range("L1").Select

Set wslb = ActiveSheet
Do Until ActiveCell.Row lastRow
MsgBox ActiveCell.Value ' Always Empty
ActiveCell.Offset(1, 0).Activate ' Move to Next Row
Loop

End Sub

In the example above if I did not have a:

Set wkst = ActiveSheet or
Set wslb = ActiveSheet

This routine works. When I add the two lines above the ActiveCell is empty.

I am trying to understand how Excel works and things like this confuse me.
In VB6 if I create a skelaton file and activate it, there is data in it.

Is this the same concept in Excel?

Thanks For the Help!

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Where is My Data

Your code worked as long as there was some data in column L. If there are
blank cells above the first entry in column L, you'll get an empty result in
the MsgBox. I would recommend that you get rid of ActiveSheet and ActiveCell
and instead reference the range directly. For example,

Dim Rng As Range
Set Rng = ThisWorkbook.Worksheets("Sheet1").Range("L1")
Do Until Rng.Row lastRow
Debug.Print Rng.Value
Set Rng = Rng(2, 1)
Loop

This way there is no ambiguity of what is the ActiveSheet and the
ActiveCell. Moreover, using Select or Activate carries considerable
overhead. It is much more efficient not to Select or Activate anything
unless absolutely necessary.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"John Quinn" wrote in message
...
In the following code the ActiveCell is always empty.

If the computer reads the WorkBook, where is the data in memory?

Option Explicit
Sub TestIntl()

Dim wkst As Worksheet
Dim wslb As Worksheet
Dim lastRow As Long

lastRow = Range("L" & Rows.Count).End(xlUp).Row
Range("L1").Select

Set wkst = ActiveSheet
Do Until ActiveCell.Row lastRow
MsgBox ActiveCell.Value ' Always Empty
ActiveCell.Offset(1, 0).Activate ' Move to Next Row
Loop

lastRow = Range("L" & Rows.Count).End(xlUp).Row
Range("L1").Select

Set wslb = ActiveSheet
Do Until ActiveCell.Row lastRow
MsgBox ActiveCell.Value ' Always Empty
ActiveCell.Offset(1, 0).Activate ' Move to Next Row
Loop

End Sub

In the example above if I did not have a:

Set wkst = ActiveSheet or
Set wslb = ActiveSheet

This routine works. When I add the two lines above the ActiveCell is
empty.

I am trying to understand how Excel works and things like this confuse me.
In VB6 if I create a skelaton file and activate it, there is data in it.

Is this the same concept in Excel?

Thanks For the Help!

John


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Labels- POssible to show data value and data label together? kippers Charts and Charting in Excel 1 April 1st 09 01:33 PM
Increase Your Business By Data Conversion, Data Format and Data EntryServices in India Data Entry India Excel Worksheet Functions 1 March 31st 08 12:51 PM
Save 20% On Data Conversion and Data Formats Services by Data EntryIndia Data Entry India Excel Discussion (Misc queries) 0 March 31st 08 12:00 PM
Data Entry Online, Data Format, Data Conversion and Data EntryServices through Data Entry Outsourcing [email protected] Excel Discussion (Misc queries) 0 March 20th 08 12:45 PM
MULTIPLE DATA - How to insert new data into existing data.... Rodorodo Excel Discussion (Misc queries) 0 December 15th 06 11:50 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"