Am very new to VBA and am using it to create a pivot chart in an worksheet. The first thing I have to do is select a range and convert the text within it to number. This is the text I have been using
This does work but it takes a long time and I was wondering if anyone would be able to advise if there's an easier way!Range("F1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select For Each xCell In Selection If IsNumeric(xCell.value) Then xCell.value = CDec(xCell.value) ActiveWindow.DisplayZeros = False Next xCell
Thanks!
Last edited by bluealex; 12-13-2011 at 08:20 AM.
Keeping your approach, this should speed thing up significantly.
ActiveWindow.DisplayZeros = False Application.ScreenUpdating = False For Each xCell In Range("F1", Range("F1").SpecialCells(xlLastCell)) If IsNumeric(xCell.Value) Then xCell.Value = CDec(xCell.Value) Next xCell Application.ScreenUpdating = True
As per forum rules, you should EDIT your post above and add code tags around your code, as I've demonstrated here.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Sorry. Am new to this too.
Am very new to VBA and am using it to create a pivot chart in an worksheet. The first thing I have to do is select a range and convert the text within it to number. This is the text I have been using
This does work but it takes a long time and I was wondering if anyone would be able to advise if there's an easier way!Range("F1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select For Each xCell In Selection If IsNumeric(xCell.value) Then xCell.value = CDec(xCell.value) ActiveWindow.DisplayZeros = False Next xCell
Thanks!
Is that right now?
Last edited by bluealex; 12-13-2011 at 07:58 AM.
Sorry and thanks for the code - will try it!
No, I didn't want you to add a new (also incorrectly formatted) post, but to EDIT post #1 to add the code tags. See my signature for the correct tags, now you'll need to fix two posts! That's ok, it's good practice for you.![]()
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Thanks very much - that worked fabulously! Sorry for all my previous formatting errors! Have read the forum rules properly now![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks