Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting text into worksheets

Status
Not open for further replies.

Crusader2

Technical User
Dec 29, 2002
11
EE
I have a work bookI don't know how many worksheets in the, but I have to write in every worksheet in a workbook some text (for example "hello world") in cell A1. I don't know worksheets number but I have to put some text in every worksheet.
 
this searches for a specific workbook but you can use the .Name property to get the names of all of the worksheets in your workbook

Public Function FindSheet(ByRef xlWbk As Excel.Workbook, _
ByVal SheetName As String) As Boolean

Dim i As Integer
Dim NumberOfWorksheets As Integer

NumberOfWorksheets = xlWbk.Sheets.Count
For i = 1 To NumberOfWorksheets
If (xlWbk.Sheets(i).Name = SheetName) Then
FindSheet = True
Exit Function
End If
Next i

FindSheet = False

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top