ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Using A Function in a Macro (https://www.excelbanter.com/excel-worksheet-functions/179906-using-function-macro.html)

Jai_Friday

Using A Function in a Macro
 
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

Bernie Deitrick

Using A Function in a Macro
 
Jai,

To process every cell with a string in it:

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

HTH,
Bernie
MS Excel MVP


"Jai_Friday" wrote in message
...
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




John Bundy

Using A Function in a Macro
 
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.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Jai_Friday" wrote:

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



All times are GMT +1. The time now is 01:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com