Converting FIND function for a Macro

Puppetgrass

New Member
Joined
Jun 30, 2009
Messages
2
Hi Everyone :) I have a workbook which I am trying to automate with a macro. This workbook has a formula which basically takes data pasted in from a third party system (standardized data) and converts it to a syntax for a different vendor system. The issue I am having is with the amounts. I have to have amounts shown as hundreds (i.e. 4.99 = 499) but because excel lops off 0's, I have to have a function to determine how many decimal places it records (i.e. 1.99 = 2 decimal places, 1.90 = 1 decimal place, 1.00 = 0 decimal places) to make sure the right number of characters are used for the amount and subsequent fields. In the workbook, I have the following formula which tells me the amount of decimal places: =LEN([CELL WITH AMOUNT])-FIND(".",[CELL WITH AMOUNT],1) Now that I am trying to do this as a macro, it seems that Find is something else. Does anyone know the best way to do this as a macro?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Welcome to the board...


look at the vba function INSTR
it does essentially the same thing as FIND
 
Upvote 0
Thanks so much! I knew there had to be an easy way but unfortunately googling on "find" brings up too non-specific results :) For reference in case this comes up in a search, it now looks like: iVar1 = Len(Cells(iCount2, iAmountcol)) - InStr(1, Cells(iCount2, iAmountcol), ".", vbTextCompare)
 
Upvote 0

Forum statistics

Threads
1,217,410
Messages
6,136,460
Members
450,013
Latest member
k4kamal

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