Pasting TextBox text

P

Patrick Simonds

Can anyone tell me why the code below, only places the text on the first
worksheet, even though all worksheets are selected?


Private Sub CommandButton1_Click()

Dim Rng

'Application.ScreenUpdating = False

Sheets(Array("June - August", "September - November", "December -
February", _
"March - May")).Select
Sheets("June - August").Activate

Range("A200").Select

Set Rng = Cells(ActiveCell.Row, 1)

Rng(1, 1).Value = TextBox1.Text
Rng(1, 2).Value = TextBox2.Text
Rng(1, 4).Value = TextBox3.Text

End Sub
 
N

Norman Jones

Hi Patrick,

Excel's ability to duplicate enties in each member of an array of grouped
sheets is not exposed to VBA.

Try instead the following adaptation of your code:

'=============>>
Private Sub CommandButton1_Click()
Dim SH As Worksheet
Dim Rng
Dim arr As Variant
Const baseCell As String = "A200"

arr = Array("June - August", "September - November", _
"December -February", "March - May")

For Each SH In Sheets(arr)

Set Rng = SH.Range(baseCell)

Rng(1, 1).Value = TextBox1.Text
Rng(1, 2).Value = TextBox2.Text
Rng(1, 4).Value = TextBox3.Text

Next SH

End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pasting TextBox values 10
Type Mismatch 1
Create a public variable 4
Return to UserForm 2
Stumped 1
Copy filtered data to sheet 2 1
store variables 4
UserForm Intialization 3

Top