ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can a excel macro be run from a .vbs file (https://www.excelbanter.com/excel-programming/445874-can-excel-macro-run-vbs-file.html)

MrPetreli

Can a excel macro be run from a .vbs file
 
Hi Guys

Can an excel macro be copied in to a .vbs script and run to (for example) format a .csv file?


EG, this script (to open book1.cvs and run this script??

Sub TrimTextRange()

Application.ScreenUpdating = False

Dim cell As Range, areaToTrim As Range
Set areaToTrim = Sheet1.Range("A1:H1000")
For Each cell In areaToTrim
cell.Value = Trim(cell.Value)
Next cell

End Sub

Harald Staff[_2_]

TrimTextRange
 
Set areaToTrim = Selection

HTH. Best wishes Harald


"MrPetreli" wrote in message
...

Hi Guys

I have a Trim text code, but how do I change it to trim only the rang
selected?

Sub TrimTextRange()

Application.ScreenUpdating = False

Dim cell As Range, areaToTrim As Range
Set areaToTrim = Sheet1.Range("A1:H1000")
For Each cell In areaToTrim
cell.Value = Trim(cell.Value)
Next cell

End Su


--
MrPetreli




All times are GMT +1. The time now is 03:05 AM.

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