How can you append data to an Excel cell on a new line (i.e. similar to hitting Alt+ENTER)? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
audante
Posts: 2
Joined: 03 Apr 2020, 18:30

How can you append data to an Excel cell on a new line (i.e. similar to hitting Alt+ENTER)?

18 Jan 2021, 13:27

I'm trying to add new text strings in a cell that already contains some text. Is there a way to append the new text or concatenate the new and existing texts but with a New Line between them? What I have so far is below.

Code: Select all

AddComment(XL,LineNumber,Comment) {

;Get current text in cell
CurrentText := XL.ActiveSheet.Range("W" LineNumber).Value

;Add new full comment
XL.ActiveSheet.Range("W" LineNumber).Value := CurrentText "Need someway to add new line (Alt+ENTER) here" Comment

}
User avatar
boiler
Posts: 6868
Joined: 21 Dec 2014, 02:44

Re: How can you append data to an Excel cell on a new line (i.e. similar to hitting Alt+ENTER)?  Topic is solved

18 Jan 2021, 16:43

Just use `n for a new line:

Code: Select all

XL.ActiveSheet.Range("W" LineNumber).Value := CurrentText "`n" Comment

Return to “Ask For Help”

Who is online

Users browsing this forum: bonswouar, hasantr, Kolonel, Lucy, nacken012, newbieforever, vmech, w64bit and 73 guests