Format a cell using vba from Access application

taspratt

New Member
Joined
Apr 7, 2002
Messages
2
I am creating an Excel spreadsheet from a table in Access 97.

For intCounter = 2 To rsRecord.fields.Count - 1
intCount = intCount + 1
oSheet.range("A" & intCount).Value = IIf(IsNull(rsRecord.fields(intCounter)), "N/A", rsRecord.fields(intCounter))
Next

Table contents:
0
9
>576
PASS

Excel after running my code:
A
1 0
2 4
3 >576
4 PASS

Populating Excel is working fine.

I have a second Excel spreadsheet that links to my newly created spreadsheet and pulls the values from the specific cells. In my second spreadsheet I need to do calculations on A1 and A2 but the field format for these cells all are General which means I can't do a numeric calculation on it - if(NewSpreadsheet![A2] >5, ">0", NewSpreadsheet![a2]), the result always turns out to be true.

I know the code in Access to check to see if the value is numeric before I write it to Excel. (Sometimes the value in A2 will be ">15", this is why I need to check to see its value.)

What code do I need in Access to format the cell to be numeric before I plug the value in?

Thanks,
Terry
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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