Formatting Data with VBA

Notadumbblonde

Board Regular
Joined
Nov 18, 2003
Messages
104
Hey Excels, Got a interesting problem.

I have a spreadsheet that all my staff keys into

I constantly do range value (sorry Lotus Term) copy special value, and then format the numbers.

Is there any way I can code:

1. To make the range I'm extracting numbers!! if currently Strings
2. Make them a predefined format, say 1 decimal point.

Any Help would greatly be appreciated.

I make use conditional formatting, but my users may be cutting and pasting from text files.
 
What would you like to happen if you have cells containing error values?
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
If you just want to let the user know, you could just show a message box

Code:
Sub nonblondeformat()
For Each cell In Range("A1:A20").Cells
 If IsNumeric(cell.Value) Then
  With cell
  .Value = .Value * 1
  .NumberFormat = "#,##0.0;(#,##0.0)"
  End With
 ElseIf IsError(cell.Value) Then
  MsgBox "Cell " & cell.Address & " is an error "
 Else
  With cell.Interior
  .ColorIndex = 6
  .Pattern = xlSolid
  End With
 End If
Next cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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