Excel Column formatting Help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
monicakes123
Posts: 6
Joined: 17 Jun 2022, 10:13

Excel Column formatting Help

Post by monicakes123 » 01 Jul 2022, 15:06

Hi!
I have the following script to (on the current excel file) auto size the columns to fit, format the specific column that is clicked.
There are some situations that the column that needs formatting is originally formatted as text. How do I get that to a number formatting (so that none of the values start with zero (before the numberFormat)). Or is there a way to be able to convert text into the "000-0000 0000" format? (which is what I actually need rather than changing the formatting twice).
Also, for the last section, I am trying to go through each column in the spreadsheet and do a text to column with no delimiters (just to make sure all the values formatting's are correct). I know I def did that part wrong. I'm not too sure how to go about that.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

f3::
oExcel := ComObjActive("Excel.Application")

;AUTOFIT COLUMNS
oExcel.ActiveSheet.Columns.AutoFit

;MAWB FORMATTING
dash := "-"
space_ := " "
blank_ := ""
Active_cell := oExcel.Selection.EntireColumn

Active_cell.replace(dash, blank_)
Active_cell.replace(space_, blank_)
Active_cell.NumberFormat := "000-0000 0000"

;TEXT TO COLUMNS
Send ^a
sleep 100
Send ^c
sleep 100
oExcel.selection.copy
oExcel.Selection.Pastespecial(-4163)

return

Thank you so much!!

Return to “Ask for Help (v1)”