• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

How to Create a File in Csv Format Taking Only Part of Data From Excel Sheet|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / How to Create a File in Csv Format Taking Only Part of Data From Excel Sheet|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosHow to Create a File in Csv Format …
sp_PrintTopic sp_TopicIcon
How to Create a File in Csv Format Taking Only Part of Data From Excel Sheet
Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
1
August 11, 2022 - 1:39 am
sp_Permalink sp_Print

Hello everyone from Maurizio
My Problem is this:
I am trying to create a Csv file by taking only data from an excel sheet

in practice I want to take all the data that I insert starting from the Cell ("A2: D17") leaving out the various Headings of the various columns.

 

Now my problem is this: The File Comes Yes ...! created inside the "Attachments" folder But when I go to open the newly created file
I notice that there is nothing inside
Because !
Therefore I ask how to solve this problem Thanks
Greetings from A.Maurizio

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
August 12, 2022 - 3:09 pm
sp_Permalink sp_Print

Try this one:

Sub Crea_File_Csv()
Dim NewWb As Workbook: Set NewWb = Workbooks.Add
ThisWorkbook.Worksheets("Sheet1").Range("A2:D17").Copy Destination:=NewWb.Worksheets(1).Cells(1)
NewWb.SaveAs Filename:=ThisWorkbook.Path & "\Allegati\Esporta.csv", FileFormat:=xlCSV, CreateBackup:=False
NewWb.Close True
End Sub

Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
3
August 13, 2022 - 2:23 am
sp_Permalink sp_Print sp_EditHistory

Image_File_Desiderato.pngImage Enlarger

Hello Catalin Bombea As always I have to congratulate you because you are fantastic .

Although I have tried several times to change everything I have never been able to get anything.

Instead with your method it works .

Therefore I thank you and Happy Ferragosto Hello from A.Maurizio

sp_PlupAttachments Attachments
  • sp_PlupImage Image_File_Desiderato.png (394 KB)
Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
4
August 19, 2022 - 2:26 am
sp_Permalink sp_Print

Hello everyone excuse me if a few days ago I entered this request of mine
but he has the strength to try the various solutions
I managed to solve my problem by creating this solution:

[CODE]

Sub Write File ()
If you make a mistake, go to finish

Dim Filename as string
Dim Path as a string
Dim Zone_Data as a string
Dim Extensionw Come String

Dim CellD as a string

Dim UltimaC until
Dim UltimaR until

Dim NewWb as a working folder
Set NewWb = Work Folders. Add

File_Name = Sheet1.Range ("N2"). Value & ""
'Extension = Worksheets ("sheet1"). Range ("O2"). Value
'Path = ThisWorkbook.Path & "\ Attachments \" & File_Name & Extension
'Data_zone = Worksheets ("sheet1"). Range ("A2: D17"). Copy
dt = Format (Time, "dd-mm-yyyy")

ThisWorkbook.Worksheets ("Sheet1"). Range ("A2: D17"). Copy destination: = NewWb.Worksheets (1) .Cells (1)

NewWb.SaveAs File name: = ThisWorkbook.Path & "\ Attachments \" & File_Name & "" & dt & "" & ".csv", FileFormat: = xlCSV, _
CreateBackup: = False, local: = True
cell = ""

'MsgBox "Hello !!!", vbInformation, "Attention"

MsgBox "Extraction completed", vbInformation, "FINISHED"

finish:
Well sub

[/CODE]

And thanks to your help, everything works wonderfully.

But now what I would like to know is this:

When the file is saved in CSV it is renamed with the words that I insert in Cell (N2)
And so far everything is ok.

But if I open this file later, I notice that this term is also used to rename the CSV sheet.

Therefore I ask how this problem can be solved.

As can be seen in this image.

While I would like to take the name I enter in the Cell (P2)
Excel Sheet!

Thank you for all the help you will want to give me on this
Greetings from A.Maurizio

Rinomina_Foglio.jpgImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage Rinomina_Foglio.jpg (79 KB)
sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Chandler Davis, baber Tufail
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
drsven
Annie Witbrod
wahab tunde
Cong Le Duc
Faisal Bashir
Ivica Cvetkovski
Blaine Cox
Shankar Srinivasan
riyepa fdgf
Hannah Cave
Forum Stats:
Groups: 3
Forums: 24
Topics: 6205
Posts: 27212

 

Member Stats:
Guest Posters: 49
Members: 31880
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.