Alternative to SendKeys

G

Garry Rathbone

Hi,
I'm writing some Access data into an Excel workbook. The
user wants some of the data to have a linebreak in a cell
(ALt-ENTER). I can simulate this using Sendkeys but
that's brutally slow and open to errors.

Any ideas how I can concatenate two pieces of text with
the equivalent of Alt-Enter between them? The code would
look something like:

objSheet.Cells(i, 5).Value = rst!Name & ????? & rst!
CashValue

Thanks for your help.

Garry
 
P

papou

Hello Garry
objSheet.Cells(i, 5).Value = rst!Name & vbLf & rst!CashValue

HTH
Regards
Pascal
 
K

keepITcool

use vbLF iso the ????? and excel will understand you..

vblf is a vba constant for chr$(10)..
using constants os more efficent that calling the chr$()
function all the time.



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Garry Rathbone wrote :
 
G

Garry Rathbone

Thanks for the prompt replies guys! I can't believe it
was that simple. I was looking for something much more
complicated. D'OH!

Garry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top