Using A Function in a Macro

J

Jai_Friday

Good Afternoon All,

I have a function built that takes a character based coded cell value and
reformats into a number with a formula.

The function works fine manually using it example =BigBookingNumber(cell
value)

However is it easy to create a macro that read sa specific column and runs
the function where there is a value (And also replace the original value)

So in a sense it take each value and puts =BigBookingNumber() around it

Thanks in Advance

Jai
 
B

Bernie Deitrick

Jai,

To process every cell with a string in it:

Dim Cell As RAnge
For Each Cell In Range("NameORAddress").SpecialCells(xlCellTypeConstants, 2)
Cell.Value = BigBookingNumber(Cell.Value)
Next Cell

HTH,
Bernie
MS Excel MVP
 
J

John Bundy

You just pass in the cell value, so if you were doing rows 1-10 for example
it would be:
For i = 1 to 10
sheet1.cells(i,1)=BigBookingNumber(sheet1.cells(i,1)
Next

not tested but this should be all you need. Depending on where you store the
Function you may need to make it a Public function or move it to the current
workbook.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top