Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Repeat value in the same cell on each sheet

I'm creating a workbook that records staff sick days and am trying to find an
easy way for the secretary to add and delete staff members as they join and
leave the company. The workbook has a Summary sheet and then a sheet for each
month of the year.

The code I've done below puts the name (keyed into a tiny userform by the
secretary) into the summary sheet, but i need that name to be placed into the
same cell on every sheet in the workbook. I suspect this is fiendishly simple
but i'm drawing a blank. Any suggestions please?



Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the textbox
Cells(intBlankRow, 1).Value = txtAddStaffName.Value
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

Function FindFirstEmptyRow()
'specify row numbers to be searched
For intRow = 1 To 100
'check if the cell in column A is empty
If IsEmpty(Cells(intRow, 1)) Then
'if so, set that variable to the row number and quit
intBlankRow = intRow
Exit Function
End If
'if not, carry on
Next intRow
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Repeat value in the same cell on each sheet

Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the
textbox
for each sh in thisworkbook.worksheets
sh.Cells(intBlankRow, 1).Value = txtAddStaffName.Value
Next sh
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

--
Regards,
Tom Ogilvy


"Katherine" wrote in message
...
I'm creating a workbook that records staff sick days and am trying to find

an
easy way for the secretary to add and delete staff members as they join

and
leave the company. The workbook has a Summary sheet and then a sheet for

each
month of the year.

The code I've done below puts the name (keyed into a tiny userform by the
secretary) into the summary sheet, but i need that name to be placed into

the
same cell on every sheet in the workbook. I suspect this is fiendishly

simple
but i'm drawing a blank. Any suggestions please?



Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the

textbox
Cells(intBlankRow, 1).Value = txtAddStaffName.Value
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

Function FindFirstEmptyRow()
'specify row numbers to be searched
For intRow = 1 To 100
'check if the cell in column A is empty
If IsEmpty(Cells(intRow, 1)) Then
'if so, set that variable to the row number and quit
intBlankRow = intRow
Exit Function
End If
'if not, carry on
Next intRow
End Function



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Repeat value in the same cell on each sheet

or with the added variable declared in case you use option explicit

Sub cmdAddStaffMember_click()
Dim Sh as Worksheet
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the
textbox
for each sh in thisworkbook.worksheets
sh.Cells(intBlankRow, 1).Value = txtAddStaffName.Value
Next sh
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the
textbox
for each sh in thisworkbook.worksheets
sh.Cells(intBlankRow, 1).Value = txtAddStaffName.Value
Next sh
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

--
Regards,
Tom Ogilvy


"Katherine" wrote in message
...
I'm creating a workbook that records staff sick days and am trying to

find
an
easy way for the secretary to add and delete staff members as they join

and
leave the company. The workbook has a Summary sheet and then a sheet for

each
month of the year.

The code I've done below puts the name (keyed into a tiny userform by

the
secretary) into the summary sheet, but i need that name to be placed

into
the
same cell on every sheet in the workbook. I suspect this is fiendishly

simple
but i'm drawing a blank. Any suggestions please?



Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the

textbox
Cells(intBlankRow, 1).Value = txtAddStaffName.Value
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

Function FindFirstEmptyRow()
'specify row numbers to be searched
For intRow = 1 To 100
'check if the cell in column A is empty
If IsEmpty(Cells(intRow, 1)) Then
'if so, set that variable to the row number and quit
intBlankRow = intRow
Exit Function
End If
'if not, carry on
Next intRow
End Function





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Repeat value in the same cell on each sheet

Excellent, thanks :)

I was doing a 'Dim sh as sheet' for some reason - D'oh! No wonder it wasn't
working.

"Tom Ogilvy" wrote:

or with the added variable declared in case you use option explicit

Sub cmdAddStaffMember_click()
Dim Sh as Worksheet
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the
textbox
for each sh in thisworkbook.worksheets
sh.Cells(intBlankRow, 1).Value = txtAddStaffName.Value
Next sh
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the
textbox
for each sh in thisworkbook.worksheets
sh.Cells(intBlankRow, 1).Value = txtAddStaffName.Value
Next sh
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

--
Regards,
Tom Ogilvy


"Katherine" wrote in message
...
I'm creating a workbook that records staff sick days and am trying to

find
an
easy way for the secretary to add and delete staff members as they join

and
leave the company. The workbook has a Summary sheet and then a sheet for

each
month of the year.

The code I've done below puts the name (keyed into a tiny userform by

the
secretary) into the summary sheet, but i need that name to be placed

into
the
same cell on every sheet in the workbook. I suspect this is fiendishly

simple
but i'm drawing a blank. Any suggestions please?



Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the

textbox
Cells(intBlankRow, 1).Value = txtAddStaffName.Value
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

Function FindFirstEmptyRow()
'specify row numbers to be searched
For intRow = 1 To 100
'check if the cell in column A is empty
If IsEmpty(Cells(intRow, 1)) Then
'if so, set that variable to the row number and quit
intBlankRow = intRow
Exit Function
End If
'if not, carry on
Next intRow
End Function






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Repeat value in the same cell on each sheet

Thanks Tom, but what do I need to define the variable sh as?

"Tom Ogilvy" wrote:

Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the
textbox
for each sh in thisworkbook.worksheets
sh.Cells(intBlankRow, 1).Value = txtAddStaffName.Value
Next sh
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

--
Regards,
Tom Ogilvy


"Katherine" wrote in message
...
I'm creating a workbook that records staff sick days and am trying to find

an
easy way for the secretary to add and delete staff members as they join

and
leave the company. The workbook has a Summary sheet and then a sheet for

each
month of the year.

The code I've done below puts the name (keyed into a tiny userform by the
secretary) into the summary sheet, but i need that name to be placed into

the
same cell on every sheet in the workbook. I suspect this is fiendishly

simple
but i'm drawing a blank. Any suggestions please?



Sub cmdAddStaffMember_click()
FindFirstEmptyRow
'set the value of the first blank cell in column A to the name in the

textbox
Cells(intBlankRow, 1).Value = txtAddStaffName.Value
'reset whats in the textbox
txtAddStaffName.Value = vbNullString
frmAdd.Hide
End Sub

Function FindFirstEmptyRow()
'specify row numbers to be searched
For intRow = 1 To 100
'check if the cell in column A is empty
If IsEmpty(Cells(intRow, 1)) Then
'if so, set that variable to the row number and quit
intBlankRow = intRow
Exit Function
End If
'if not, carry on
Next intRow
End Function






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I enter rows to repeat on sheet tab? Geoff W Excel Discussion (Misc queries) 8 March 1st 10 06:46 AM
How do I fill a formula on another sheet that repeat every 50 cell Chad Hable Excel Discussion (Misc queries) 2 December 31st 07 11:14 PM
How do I fill a formula on another sheet that repeat every 50 cell Chad Hable[_2_] Excel Worksheet Functions 3 December 31st 07 07:35 PM
Repeat formula on second sheet? [email protected] Excel Discussion (Misc queries) 3 August 30th 07 09:45 PM
how can I repeat row heights in the same sheet Khalil Excel Discussion (Misc queries) 1 December 6th 05 07:34 PM


All times are GMT +1. The time now is 05:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"