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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting data into cells on a different spreadsheet - help please

Status
Not open for further replies.

MrDougJ

Technical User
Feb 25, 2009
8
US
I am trying to write code where the user enters data into 3 text boxes, then presses a button. The data inputted is then written in that worksheet and then another worksheet in the same file.

When run, the data is written in the cells of the 1st spreadsheet but then i get a bug on the "Range("B4").Activate" line when in the 2nd worksheet.

Any advice?



Private Sub Enter_Click()

Datein = DateBox.Text
Unit = UnitBox.Text
Failure = FailureBox.Text

Sheets("Form").Select
Range("B4").Activate
ActiveCell.FormulaR1C1 = Datein
Range("C4").Activate
ActiveCell.FormulaR1C1 = Unit
Range("D4").Activate
ActiveCell.FormulaR1C1 = Failure

Sheets("All Failure Records").Select
Range("B4").Activate
ActiveCell.FormulaR1C1 = Datein
Range("C4").Activate
ActiveCell.FormulaR1C1 = Unit
Range("D4").Activate
ActiveCell.FormulaR1C1 = Failure

End Sub
 


Hi,

Reference each sheet explicitly and WITHOUT using the activate of select method, assign the value...
Code:
Sheets("Form").Range("B4").Value = Datein


Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
hi,
probably you already follow this strategy,
but when I have to build these operations,
I put excel in "Recording Macro", I complete operations,
stop recording, then I look the macro. ;-)

ciao
vittorio
 
In future it would probably be better if you asked VBA questions in the VBA forum: forum707

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top