Thread: Userform Add
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
hazel hazel is offline
external usenet poster
 
Posts: 114
Default Userform Add

Gentlemen

It is a beautiful day here in the UK -- and you have both made it more
gorgeous with your solving of my question - my boss has just thrown me
another question as we work to quarter periods throughout the year e.g.
01/11/06 to 31/01/07 on the 01/02/07 is it possible for the Tb1 value on the
01/02/07 to automatically enter cell D7 instead of B7 on that date. Once
again thank you everything much appreciated.

--
Many thanks

hazel


"Dave Peterson" wrote:

Maybe....

Replace this line:
Sheets("Income Expense 2007").Range("B7") = Tb1.Value

with this set of lines:

with Sheets("Income Expense 2007").range("B7")
if isnumeric(.value) then
.value = .value + Tb1.Value
end if
end with

An empty cell is treated as a numeric cell (value = 0) by VBA)

If that cell is not numeric, what should happen?

with Sheets("Income Expense 2007").range("B7")
if isnumeric(.value) then
.value = .value + Tb1.Value
else
.value = tbl.value
'or
'.value = "ERROR"
end if
end with


Hazel wrote:

Hi All

Using the following code below my userform adds to the designated sheet if
there is a value already in the cell is it possible for the new value added
in Tb1 to add to the value already in the cell and show the new value in the
same cell. e.g the cell B7 has a value of 100 and I add 200 in Tb1 then click
on Add1 cell B7 would then show 300.

Private Sub Add1_Click()

startrownum = 7
endrownum = 25
For rownum = startrownum To endrownum
If Trim(Sheets("Income Expense 2007").Range("A" & Trim(Str(rownum)))) =
"" Then
freerownum = rownum
rownum = endrownum
End If
Next rownum

Sheets("Income Expense 2007").Range("A" & Trim(Str(freerownum))) = Com1.Value
Sheets("Income Expense 2007").Range("B7") = Tb1.Value

End Sub

--
Many thanks

hazel


--

Dave Peterson