Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old September 16th, 2003, 12:34 PM
hozerman hozerman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Chicago
Posts: 2 hozerman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question vba changing cell text

Using Excel 2000

Problem:

I want to change the text/value of a cell programmatically.

For testing purposes, i've used the following formula.
=IF(Q40>AH40,"YES","NO")

But instead of returning a "YES" or a "NO" to the current cell containing the formula, i'd like to change the value of a different cell (increment the current value by 1).

Issue:

Using a VBA function is not working, it reaches the code line that populates the cell with the new incremented value, then nothing. It neither updates the cell nor finishes the function.

Code:

'Neither of the following will work
'lngStock1 is a long variable = to the incremented value

Worksheets("List").Cells(1, "B").Value = lngStock1
Worksheets("List").Cells(1, "B").Formula = "=" & lngStock1 & "+1"
Worksheets("List").Cells(1, "B").Value = "4"

'Placing that same code inside a button click does work only
'if the user clicks the button however

Private Sub cmdTWH_Click()
Worksheets("List").Cells(lngStock1, "L").Formula = "=" & lngStock1 & "+1"
Worksheets("List").Cells(lngStock2, "L").Formula = "=" & lngStock2 & "+1"

End Sub



Any help would be appreciated because my boss is getting impatient!!

~Tony Huss

Reply With Quote
  #2  
Old September 18th, 2003, 09:22 AM
hozerman hozerman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Chicago
Posts: 2 hozerman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well, i came up with a makeshift solution to my problem.

I have the user press a button to activate the sheet. I used Application.OnTime to create a timer and a global variable.

The global variables hold information that will used to update other cells.
The timer is periodically called and uses a simple "if" statement to test the global variables.

If glngS1 > 0 And glngS2 > 0 Then
'do code, update cells
'reset globals to zero
glngS1=0
glngS2=0
end if

This is not the most elegant way to solve my original problem, but sometimes you have to go with what works and hope a better solution comes along.

Included is a nice link to an example of using the Application.OnTime

Planet source code OnTime Example

~Tony

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > vba changing cell text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway