View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
chris:Use this code chris:Use this code is offline
external usenet poster
 
Posts: 1
Default Cell Formulas vs. VBA

Follow these steps.
Note: This code assumes all relevant data for each admit date is located in the same row

Name the Range where Your Admit dates are entered Admit_Date using: Insert Name Defin

Name the Range where Your Patient Names are entered Patient_Name using: Insert Name Defin

Name the Range where Your Due Dates are entered Due_Date14 using: Insert Name Defin
Due_Date30..

Go to you Projects window. dbl-click your worksheet, should look like: Sheet1("xxxxx"

In your code window(to the Right), In left dropdown box choose Worksheet,
In Right dropdown box choose Chang

In the The worksheets Change event put in this code

Private Sub Worksheet_Change(ByVal Target As Range)'<< Provide
On Error Resume Nex
isect = Application.Intersect(Target, Range("AdmitDate")
If isect Is Nothing Then exit su
If Target ="" Then Exit Su
If Target.Cells.Count = 1 And IsDate(Target.value) And
Cells(Target.Row, Range(" Patient_Name").Column).Value<"" The

Cells(Target.Row, Range(" Due_Date14").Column).Value = CDate(Target.Value +14
Cells(Target.Row, Range(" Due_Date30").Column).Value = CDate(Target.Value +30
Cells(Target.Row, Range(" Due_Date60").Column).Value = CDate(Target.Value +60
' Put more as neede
End i
End Su
You may need to do a save and close to force code to activate for first time
Now, any time you enter a new admit date this code will fire and fill in the rest of the fields for you


----- Ruan wrote: ----

Hello

I have an excel workbook that has a worksheet that consists of 30 column
with 1000 rows

One of my main columns of input is the Admit Date of a Patient. From th
Admit Date, various Due Dates are generated at specific points in tim
(ie.14 days, 30 days, 60 days etc

So, I would have a formula as follows
=IF(AND(Patient_Name<"",Admit_Date<""),Admit_Dat e+30,""

My question is, which direction is more efficient
1) Creating formulas that are copied for 1000 rows o
2) Creating VBA code that only enters the result once an input has bee
entered in the Admit Date column

I am trying to figure out ways to reduce my 10 Mbs excel workbook

Thank
Rua