Selasa, 01 November 2011

RE: [ExcelVBA] Assigning value to a cell

 

Firstly ... why it disappears rather than throwing an error ... I'm
assuming that this line of code is in an event handler, e.g. a change
event. When Excel encounters a problem in an event handler, it
terminates the event without further notification.


> Sheets("Adjustments").cells(3,2)=">=" & D1

This requires that you have a sheet called Adjustments and a variable
called D1. I suspect you actually want to refer to the cell D1, which
will require a Range("D1"), possibly also with a sheet qualifier.

Also, please use .Value or .Formula as appropriate, so that Excel knows
where to put/get the information, so

> Sheets("Adjustments").cells(3,2).Value = ">=" & Range("D1").Value

Also, if D1 has a date in it, then you probably want to convert it to a
date string before you append it to the >=. Otherwise you'll just get
the numeric value of the date, I suspect.

Regards, Dave S

________________________________

From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On
Behalf Of BarryN
Sent: Wednesday, 2 November 2011 01:16
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] Assigning value to a cell

I've done this dozens of times but when I step through a function to
this line of code:

Sheets("Adjustments").cells(3,2)=">=" & D1

where D1 is a date, the yellow line disappears and the function stops.

Obvious solution but I can't see it - thanks!

----------

Visit our website at http://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.

UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar