Excel Set Range Format

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Neib74656
Junior Coder
Posts: 29
Joined: Fri Sep 10, 2021 10:51 pm

Excel Set Range Format

Post by Neib74656 » Mon Feb 07, 2022 2:13 am

Hello Everyone,

I am trying to get MS to set a range in Excel to Text format. I have gone through the Excel documentation as suggested in the manual but no luck.

Specific bit of code I am using is the below but I can not figure out what the format part of this should be

XLSetRangeFormat>XY,Sheet1,B2:B10000,

Thanks for any help you can provide.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Excel Set Range Format

Post by Dorian (MJT support) » Mon Feb 07, 2022 8:59 am

I wasn't too sure either, so I recorded an Excel macro to format text and looked to see what it created.

This was the result :

Code: Select all

Sub Macro1()
'
' Macro1 Macro
'

'
    Range("D3:E6").Select
    Selection.NumberFormat = "@"
End Sub
So :

Code: Select all

XLSetRangeFormat>xlh,FormatTest,B2:B10000,@
Yes, we have a Custom Scripting Service. Message me or go here

Neib74656
Junior Coder
Posts: 29
Joined: Fri Sep 10, 2021 10:51 pm

Re: Excel Set Range Format

Post by Neib74656 » Sun Jul 17, 2022 7:18 am

This worked perfectly thanks very much!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts