kevinc1973
New Member
- Joined
- Jun 20, 2019
- Messages
- 26
Good afternoon,
I have a user form with a multiple textboxes and what I would like to do is to have the textboxes with no value in it not to write to the spreadsheet and overwrite what was already there. This is what I have for code.
End Sub
I did have a code that looked like this ( yes it is to a different user form than what I have listed above)
This code did work as far as leaving the cell alone but it was writing to a different sheet that is not even in the code.
Thanks for your help in advance.
I have a user form with a multiple textboxes and what I would like to do is to have the textboxes with no value in it not to write to the spreadsheet and overwrite what was already there. This is what I have for code.
VBA Code:
Private Sub CMDADD_Click()
Sheets("Chlor_Dechlor").Range("c" & Day(TextBox1.Value) + 10) = TextBox2.Text
Sheets("Chlor_Dechlor").Range("d" & Day(TextBox1.Value) + 10) = TextBox3.Text
Sheets("Chlor_Dechlor").Range("g" & Day(TextBox1.Value) + 10) = TextBox5.Text
Sheets("Chlor_Dechlor").Range("h" & Day(TextBox1.Value) + 10) = TextBox6.Text
Sheets("Chlor_Dechlor").Range("j" & Day(TextBox1.Value) + 10) = TextBox8.Text
Sheets("Chlor_Dechlor").Range("v" & Day(TextBox1.Value) + 10) = TextBox8.Text
Sheets("Chlor_Dechlor").Range("ag" & Day(TextBox1.Value) + 10) = TextBox8.Text
Sheets("Chlor_Dechlor").Range("as" & Day(TextBox1.Value) + 10) = TextBox8.Text
Sheets("Chlor_Dechlor").Range("t" & Day(TextBox1.Value) + 54) = TextBox8.Text
Sheets("Chlor_Dechlor").Range("i" & Day(TextBox1.Value) + 54) = TextBox8.Text
Sheets("Chlor_Dechlor").Range("l" & Day(TextBox1.Value) + 97) = TextBox8.Text
Sheets("Chlor_Dechlor").Range("l" & Day(TextBox1.Value) + 10) = TextBox15.Text
Sheets("Chlor_Dechlor").Range("o" & Day(TextBox1.Value) + 10) = TextBox16.Text
Sheets("Chlor_Dechlor").Range("p" & Day(TextBox1.Value) + 10) = TextBox17.Text
Sheets("Chlor_Dechlor").Range("s" & Day(TextBox1.Value) + 10) = TextBox18.Text
Sheets("Chlor_Dechlor").Range("t" & Day(TextBox1.Value) + 10) = TextBox19.Text
Sheets("Chlor_Dechlor").Range("x" & Day(TextBox1.Value) + 10) = TextBox21.Text
Sheets("Chlor_Dechlor").Range("aa" & Day(TextBox1.Value) + 10) = TextBox22.Text
Sheets("Chlor_Dechlor").Range("ad" & Day(TextBox1.Value) + 10) = TextBox23.Text
Sheets("Chlor_Dechlor").Range("ae" & Day(TextBox1.Value) + 10) = TextBox24.Text
Sheets("Chlor_Dechlor").Range("ai" & Day(TextBox1.Value) + 10) = TextBox26.Text
Sheets("Chlor_Dechlor").Range("am" & Day(TextBox1.Value) + 10) = TextBox27.Text
Sheets("Chlor_Dechlor").Range("an" & Day(TextBox1.Value) + 10) = TextBox28.Text
Sheets("Chlor_Dechlor").Range("ap" & Day(TextBox1.Value) + 10) = TextBox29.Text
Sheets("Chlor_Dechlor").Range("aq" & Day(TextBox1.Value) + 10) = TextBox30.Text
Sheets("Chlor_Dechlor").Range("au" & Day(TextBox1.Value) + 10) = TextBox32.Text
Sheets("Chlor_Dechlor").Range("n" & Day(TextBox1.Value) + 54) = TextBox33.Text
Sheets("Chlor_Dechlor").Range("q" & Day(TextBox1.Value) + 54) = TextBox34.Text
Sheets("Chlor_Dechlor").Range("r" & Day(TextBox1.Value) + 54) = TextBox35.Text
Sheets("Chlor_Dechlor").Range("v" & Day(TextBox1.Value) + 54) = TextBox37.Text
Sheets("Chlor_Dechlor").Range("c" & Day(TextBox1.Value) + 54) = TextBox38.Text
Sheets("Chlor_Dechlor").Range("f" & Day(TextBox1.Value) + 54) = TextBox39.Text
Sheets("Chlor_Dechlor").Range("g" & Day(TextBox1.Value) + 54) = TextBox40.Text
Sheets("Chlor_Dechlor").Range("k" & Day(TextBox1.Value) + 54) = TextBox42.Text
Sheets("Chlor_Dechlor").Range("f" & Day(TextBox1.Value) + 97) = TextBox43.Text
Sheets("Chlor_Dechlor").Range("g" & Day(TextBox1.Value) + 97) = TextBox44.Text
Sheets("Chlor_Dechlor").Range("i" & Day(TextBox1.Value) + 97) = TextBox45.Text
Sheets("Chlor_Dechlor").Range("j" & Day(TextBox1.Value) + 97) = TextBox46.Text
Sheets("Chlor_Dechlor").Range("n" & Day(TextBox1.Value) + 97) = TextBox48.Text
Sheets("Chlor_Dechlor").Range("c" & Day(TextBox1.Value) + 97) = TextBox49.Text
Sheets("Chlor_Dechlor").Range("d" & Day(TextBox1.Value) + 97) = TextBox50.Text
Unload Me
ThisWorkbook.Sheets("Main Page").Activate
Plantsidepolymer.Show
End Sub
I did have a code that looked like this ( yes it is to a different user form than what I have listed above)
VBA Code:
Set ws = Worksheets("Coagulants")
If TextBox2 <> "" Then Cells.Range("c" & Day(TextBox1.Value) + 9) = TextBox2.Value
If TextBox3 <> "" Then Cells.Range("D" & Day(TextBox1.Value) + 9) = TextBox3.Value
If TextBox4 <> "" Then Cells.Range("E" & Day(TextBox1.Value) + 9) = TextBox4.Value
If TextBox5 <> "" Then Cells.Range("H" & Day(TextBox1.Value) + 9) = TextBox5.Value
If TextBox6 <> "" Then Cells.Range("I" & Day(TextBox1.Value) + 9) = TextBox6.Value
Range("k" & Day(TextBox1.Value) + 9) = TextBox8.Text
Range("k" & Day(TextBox1.Value) + 53) = TextBox8.Text
Range("w" & Day(TextBox1.Value) + 53) = TextBox8.Text
If TextBox9 <> "" Then Cells.Range("c" & Day(TextBox1.Value) + 53) = TextBox9.Value
If TextBox10 <> "" Then Cells.Range("D" & Day(TextBox1.Value) + 53) = TextBox10.Value
If TextBox11 <> "" Then Cells.Range("E" & Day(TextBox1.Value) + 53) = TextBox11.Value
If TextBox12 <> "" Then Cells.Range("H" & Day(TextBox1.Value) + 53) = TextBox12.Value
If TextBox13 <> "" Then Cells.Range("i" & Day(TextBox1.Value) + 53) = TextBox13.Value
If TextBox15 <> "" Then Cells.Range("m" & Day(TextBox1.Value) + 9) = TextBox15.Value
If TextBox16 <> "" Then Cells.Range("M" & Day(TextBox1.Value) + 53) = TextBox16.Value
If TextBox17 <> "" Then Cells.Range("p" & Day(TextBox1.Value) + 53) = TextBox17.Value
If TextBox18 <> "" Then Cells.Range("q" & Day(TextBox1.Value) + 53) = TextBox18.Value
If TextBox19 <> "" Then Cells.Range("t" & Day(TextBox1.Value) + 53) = TextBox19.Value
If TextBox20 <> "" Then Cells.Range("u" & Day(TextBox1.Value) + 53) = TextBox20.Value
If TextBox22 <> "" Then Cells.Range("y" & Day(TextBox1.Value) + 53) = TextBox22.Value
Unload Me
ThisWorkbook.Save
Plantsidecollectiionsystem.Show
This code did work as far as leaving the cell alone but it was writing to a different sheet that is not even in the code.
Thanks for your help in advance.