VBS replace function

oso_togari

New Member
Joined
Sep 1, 2016
Messages
20
Hello all

im making a VBS to manipulate excel file..
in one part i fill cells with formulas:

objexcel.Range("B2").formula = "=espacios(A2)"
objExcel.Range("B2","B" & ws.Cells(ws.Rows.Count, 1).End(xlUp).Row).FillDown

but in the excel the formulas appears with "@" preceeding the function.
if i manually delete the "@" in the excel it works as expected...but i want to know how to replace in vbs

im using:
objExcel.Range("B:D").Replace "@","
and
objExcel.Range("B:D").Replace "@","",,,,,,1
objExcel.Range("B:D").Replace "@","",,,,,,xlreplceformula2 (this come from a macro recording)

but no luck...any ideas?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try using Fornual2 rather than formula
VBA Code:
objExcel.Range("B2").Formula2 = "=espacios(A2)"
 
Upvote 0
Thank you

it partially works!! but the excel still remains with #¿NOMBRE? value....only if enter the cell and do a simple enter...then it takes the formula correctly...

why this??
 
Upvote 0
What if you try
VBA Code:
objExcel.Range("B2").Formula2 = "=Trim(A2)"
 
Upvote 0
Solution
If you want to use the excel language version try
VBA Code:
.Formula2Local
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

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