• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vba to copy used range ,format text and save in directory

Status
Not open for further replies.

RAM72

Member
Hi
Copy used range as per attached as sample , format used range as text format to last data row, there are blank columns in the middle of used range

add a new workbook with 1 sheet only rename sheet tab as cell b1 of summary workbook (note there is a /) so to rename e.g aaa_10 and save file in csv ms dos format in c:\\upload which already exists.
 

Attachments

  • summary.xlsx
    15.1 KB · Views: 6
  • beat_10csv.txt
    391 bytes · Views: 4
Hi !​
(note there is a /) so to rename e.g aaa_10 and save file in csv​
So once you have corrected B1 cell, run this demonstration
to save Sheet2 used range data to a csv text file :​
Code:
Sub Demo1()
     Const FOLDER = "C:\upload\"
        On Error Resume Next
    If Dir(FOLDER & ".") = "" Then Beep: Exit Sub
        On Error GoTo 0
    With Sheet2.UsedRange.Rows
            If .Cells(2).Value = "" Then Beep: Exit Sub
            FF% = FreeFile
            Open FOLDER & .Cells(2).Value & ".csv" For Output As #FF
        For R& = 1 To .Count
            Print #FF, Join(Application.Index(.Item(R).Resize(2).Value, 1), ",")
        Next
            Close #FF
    End With
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
Hi !​

So once you have corrected B1 cell, run this demonstration
to save Sheet2 used range data to a csv text file :​
Code:
Sub Demo1()
     Const FOLDER = "C:\upload\"
        On Error Resume Next
    If Dir(FOLDER & ".") = "" Then Beep: Exit Sub
        On Error GoTo 0
    With Sheet2.UsedRange.Rows
            If .Cells(2).Value = "" Then Beep: Exit Sub
            FF% = FreeFile
            Open FOLDER & .Cells(2).Value & ".csv" For Output As #FF
        For R& = 1 To .Count
            Print #FF, Join(Application.Index(.Item(R).Resize(2).Value, 1), ",")
        Next
            Close #FF
    End With
End Sub
Do you like it ? So thanks to click on bottom right Like !


Hi
Tested but getting some issues, try on desktop and c:\\upload
Got same error run time error 424 object required

With Sheet2.UsedRange.Rows in yellow.

Advise where I am going wrong
 
Did you at least test with your attachment ? As it rocks on my side …

You can change the Sheet2 CodeName
to the Worsheets reference by an index or a name …
______________________________________________________________
Mod edit : thread closed (wild cross posting aka JEAN1972 !)
 
Status
Not open for further replies.
Back
Top