View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter[_28_] Peter[_28_] is offline
external usenet poster
 
Posts: 60
Default Help with VB script please?

Hi,

I'm having a little trouble with the following VB. What it's meant to
do is to load the contents of a text box and two combo boxes into
particular cells in a spreadsheet - This bit is OK. However, it is
also meant to copy the same data into three celss on a different
worksheet (one that is created when the form used is launched), but
what it does is copy the contents of the text box into all three
cells, ignoring what is in the combo boxes. Obviously something wrong
with my VB script, but cannot see exactly what.

Any suggestions would be much appreciated.

Private Sub CommandButton1_Click()

Dim rng As Range

Set rng = Cells(Rows.Count, "A").End(xlUp)(2)
rng.Value = TextBox1
Selection.copy
Sheets("Form master (2)").Select
Range("B3").Select
Selection.PasteSpecial Paste:=xlValues
Sheets("Main").Select

Sheets("Main").Select
Set rng = Cells(Rows.Count, "B").End(xlUp)(2)
rng.Value = ComboBox1
Selection.copy
Sheets("Form master (2)").Select
Range("B7").Select
Selection.PasteSpecial Paste:=xlValues
Sheets("Main").Select

Set rng = Cells(Rows.Count, "C").End(xlUp)(2)
rng.Value = ComboBox2
Selection.copy
Sheets("Form master (2)").Select
Range("B11").Select
Selection.PasteSpecial Paste:=xlValues
Sheets("Form master (2)").Select
Sheets("Form master (2)").Name = (TextBox1.Text)


--
Cheers

Peter

Remove the INVALID to reply