CSV File to Excel File with Dynamic Graphing Capability

JCRon

New Member
Joined
May 13, 2015
Messages
4
Hi I would like to know if my theory is possible for beginners like me in using VBA

Goal:
1. To create an automatic converter of CSV File to Excel Worksheet
------------> Until this part, it is successful.
2. To create graph according to the converted CSV File with the user only choosing the Type of graph to display and the Column for X and Y Values. This must be done also simultaneously with the conversion of CSV File to Excel
------------> This is the hard part and I dont know if its possible.

Thank you!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
This is a great tutorial, but far too long for an answer here. I'll write it up on my blog next week.
 
Upvote 0
Hi Jon,

That would be a really big help to me.

I am looking forward for your tutorial.

Thank you in Advance.
 
Upvote 0
I'm working on it. The tutorial will probably be up early next week.
 
Upvote 0
Oh Hi again!

I have one last question.

How about if my CSV File was delimited by Semi Colon?
I tried changing this part: (On Parsing Part)
Code:
[COLOR=#333333]sTemp = sTemp & vRng(iRow, iCol) & ", "[/COLOR]

with
Code:
[COLOR=#333333]sTemp = sTemp & vRng(iRow, iCol) & "; "[/COLOR]

but with no luck. The converted csv file was still separated by semi colon.


THANKSS!
 
Upvote 0
Okay, so if it's delimited by semicolons, it's not a CSV file, since CSV = Comma Separated Values. Do everyone, including but not limited to yourself, a favor, and don't call a file a CSV file unless it's a Comma Separated Values file.

So rename the file with a .txt extension, and make the following changes:

Old code:
Code:
  Dim sCSVFullName As String
  sCSVFullName = Application.GetOpenFilename("CSV Files (*.csv), *.csv", , _
      "Select a CSV file", , False)
  Dim wb As Workbook
  Workbooks.Open sCSVFullName
  Set wb = ActiveWorkbook
  Dim sWbkFullName As String, sFileRoot As String
  sFileRoot = Left$(sCSVFullName, InStrRev(sCSVFullName, ".") - 1)

New code:
Code:
  Dim sTXTFullName As String
  sTXTFullName = Application.GetOpenFilename("TXT Files (*.txt), *.txt", , _
      "Select a TXT file", , False)
  Dim wb As Workbook
  Workbooks.Open Filename:=sTXTFullName, Semicolon:=True
  Set wb = ActiveWorkbook
  Dim sWbkFullName As String, sFileRoot As String
  sFileRoot = Left$(sTXTFullName, InStrRev(sTXTFullName, ".") - 1)

If you try to open a CSV file using Semicolon:=True, Excel will override this and only use commas. So all the more reason to not abuse the CSV definition.

You could always use Text to Columns to get around the problem, but that leaves the problem in place.
 
Upvote 0
I should note that the blog post from yesterday is a simple solution, and a more useful one will follow in another day or two. The better solution has some error checking and user-tedium-prevention things about it, though it would not have helped with the comma-semicolon issue.
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,619
Members
449,039
Latest member
Mbone Mathonsi

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