set range error in add sheet
On Dec 5, 6:34 am, "Mike Fogleman" wrote:
Sub CreateSheet()
Dim ws as Worksheet
Dim Found As Boolean
For Each ws in ThisWorkbook.Worksheets
If ws.Name = "bugun" Then Found = True
Next
If Found = True Then
'do nothing
Else
Worksheets.Add.Name = "bugun"
End If
End Sub
Mike wrote in message
...
On Dec 4, 6:39 am, "Mike Fogleman" wrote:
You just added a new worksheet, so it is now the activesheet. What are
you
trying to find on a new empty sheet?
Where is this code located? In a worksheet module?
Mike wrote in message
...
Hi All,
I am getting runtime error on below code,anyone can give a hand why
that happens?Thanks in advance.
Sub sukre()
Dim pn
Dim rng As Range
pn = ComboBox1.Value
bugun = Format(Date, "[$-409]d-mmm-yy;@")
If CheckBox1.Value = True Then
pn = OTB.Value
End If
Sheets.Add.Name = bugun
Set rng = Range("a1:a10000")
rng.Find("", rng(rng.Rows.Count)).Select ' HERE IS WHERE I AM
HAVING AN ERROR
Selection.Value = bugun
ActiveCell.Offset(0, 1).Value = pn
ActiveCell.Offset(0, 2).Value = PitUF.DTB.Value
ActiveCell.Offset(0, 3).Value = PitUF.RTB.Value
PitUF.ComboBox1 = ""
PitUF.OTB = ""
PitUF.DTB = ""
PitUF.RTB = ""
PitUF.ComboBox1.SetFocus
End Sub
what can I say you are right.I never thought in that way.By the way
how can i check if the sheet already exist or not?if not exist then
create the sheet name bugun?
thanks for your reply
Thanks a lot for your help,that work for me.
have a nice day
|