Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default how do I extract data from worksheet to VBA?

Using the Loop example from Excel Help -
For Each c In Worksheets("Sheet1").Range("A1:D10").Cells
If Abs(c.Value) < 0.01 Then c.Value = 0
Next
I've tried to use it to extract data FROM Excel by assigning a variable to:
Variable = ActiveCell.Value.

This doesn't work. Also, the ActiveCell not appear to interate through the
For Each Loop.

How do I extract a range of data into a VBA array?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default how do I extract data from worksheet to VBA?

You're not changing the activecell.

But you could use:
Variable = C.Value.



Bob Allen wrote:

Using the Loop example from Excel Help -
For Each c In Worksheets("Sheet1").Range("A1:D10").Cells
If Abs(c.Value) < 0.01 Then c.Value = 0
Next
I've tried to use it to extract data FROM Excel by assigning a variable to:
Variable = ActiveCell.Value.

This doesn't work. Also, the ActiveCell not appear to interate through the
For Each Loop.

How do I extract a range of data into a VBA array?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 897
Default how do I extract data from worksheet to VBA?

Try this:

Dim arrRange As Variant
arrRange = ActiveSheet.Range("A1:D10").Value

--JP

On Jul 31, 4:20*pm, Bob Allen
wrote:

How do I extract a range of data into a VBA array?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default how do I extract data from worksheet to VBA?

Sub ifvaluelessthan()
mv = 0.01
On Error Resume Next
For Each c In Worksheets("Sheet5").Range("A1:D10")
If Not IsEmpty(c) And IsNumeric(c) And Abs(c) < mv Then c.Value = 0
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Bob Allen" wrote in message
...
Using the Loop example from Excel Help -
For Each c In Worksheets("Sheet1").Range("A1:D10").Cells
If Abs(c.Value) < 0.01 Then c.Value = 0
Next
I've tried to use it to extract data FROM Excel by assigning a variable
to:
Variable = ActiveCell.Value.

This doesn't work. Also, the ActiveCell not appear to interate through
the
For Each Loop.

How do I extract a range of data into a VBA array?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default how do I extract data from worksheet to VBA?

On Fri, 31 Jul 2009 13:20:01 -0700, Bob Allen
wrote:

How do I extract a range of data into a VBA array?



Here's a simple method:

Option Explicit
Sub GetArray()
Dim rg As Range
Dim a As Variant
Set rg = Range("A1:D10")
a = rg.Value
End Sub

a will turn into a 2D array, with each element containing the value in one of
the cells in rg.

a : Variant/Variant(1 to 10, 1 to 4)
--ron
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
extract data from another worksheet G&GSolutions Excel Discussion (Misc queries) 0 February 25th 09 02:29 PM
extract data from worksheet T3st3r Excel Discussion (Misc queries) 0 June 19th 08 10:15 PM
Extract data from one worksheet SKY Excel Worksheet Functions 5 April 27th 06 01:48 PM
Extract data from one Worksheet to another extract data fr. one worksheet to anothe Excel Worksheet Functions 1 August 15th 05 07:11 PM
extract data from worksheet sallu Excel Worksheet Functions 2 February 21st 05 06:50 AM


All times are GMT +1. The time now is 04:10 PM.

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

About Us

"It's about Microsoft Excel"