If you want to save the filtered data in an array using VBA.
Here is the code-
Option Explicit
Sub store_filtered_data_in_array()
Application.DisplayAlerts = False
Dim ap As Workbook, i As Long
Dim z
' copy the filtered data
Sheets(1).Range("a1:c100").SpecialCells(xlCellTypeVisible).Copy
' add a new workbook
Set ap = Workbooks.Add
' paste data to new workbook
Range("a1").Select
ActiveSheet.Paste
' store data to an array
z = Range("a1:c" & Range("a1").End(xlDown).Row)
' close the new workbook without saving as we don't require it.
ap.Close
' use the data stored in an array
For i = LBound(z) To UBound(z)
MsgBox z(i, 1)
MsgBox z(i, 2)
MsgBox z(i, 3)
Next
Application.DisplayAlerts = True
End Sub
Showing posts with label Save Filtered Data in a Array. Show all posts
Showing posts with label Save Filtered Data in a Array. Show all posts
Sunday, February 19, 2012
Subscribe to:
Posts (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
Macro to Export Range in Json Format Option Explicit Sub export_in_json_format() Dim fs As Object Dim jsonfile Dim rangetoex...
-
If you want to run SQL queries within Excel environment without connecting to any database, you can do it with creating the ADODB conn...