Array data to new CSV file

shayanhaque

New Member
Joined
Mar 13, 2019
Messages
19
Below is my code:

I'm trying to store data into an array, once its done trying to open new sheet and paste array data into new sheet's column A. It opens new sheet but doesn't unload data into new sheet. Please assist.

Sub LoadArray()

Dim TotalRows As Long
Dim x As Integer
Dim i As Integer
Dim zArray As Variant
Dim ws As Worksheet
Dim rng As Range



Dim strArray As Variant


TotalRows = Rows(Rows.Count).End(xlUp).Row
x = WorksheetFunction.CountA(Worksheets(1).Columns(1))

ReDim strArray(x)
For i = 1 To x
strArray(i) = Cells(i, 1).Value
Range("v1").Offset(i - 1, 0).Value = strArray(i)


Next i
Set newbook = Workbooks.Add
With newbook
ActiveSheet.Range("a1").Value = Application.WorksheetFunction.Transpose(strArray)



MsgBox "Loaded " & UBound(strArray) & " items!"
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
How about
Code:
Sub shayanhaque()
   Dim Ary As Variant
   Dim NewBk As Workbook
   
   Ary = Range("A1", Range("A" & Rows.Count).End(xlUp)).Value2
   Range("V1").Resize(UBound(Ary)).Value = Ary
   Set NewBk = Workbooks.Add
   NewBk.Sheets(1).Range("A1").Resize(UBound(Ary)).Value = Ary
   MsgBox "Loaded " & UBound(Ary) & " items!"
End Sub
 
Upvote 0
Turn on the macro recorder & save the file as a csv, you then have the code.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top