VBA Code to drop values in cells at the same time

Malcolm torishi

Board Regular
Joined
Apr 26, 2013
Messages
219
I have the following code that drops a calendar value and 2 textbox values into a 3 cells on my spread sheet that then triggers an email to be sent if the total of the 3 values that are dropped is below a certain value, but what is happening is when the values get dropped rather than being dropped in one go they get dropped in one at a time, albeit it’s a split second between each drop.
What I would like the code to do is drop all 3 values in the cells at the same time so there’s no time lag, does any know how this can be done please

Thank you

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
ActiveWorkbook.Sheets("OUT").Activate
Range("AC5").Value = 1
Range("AO7").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Offset(0, 0) = Calendar1.Value
ActiveCell.Offset(0, 1) = TextBox1.Value
ActiveCell.Offset(0, 2) = TextBox2.Value
Range("AC5").Value = 0
Range("AB4").Select
Application.ScreenUpdating = True
End Sub
 
Hello Fluff
you asked me to let you know how I got on, well for some strange reason, I could not get the code to drop the values from either the calendar or TextBox,s into the cell range on my spread sheet. Is it me?..
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Does AO7 have anything in it? If so do you have values below that with no blanks anywhere in that column?
 
Last edited:
Upvote 0
In that case check the very last row of your sheet, you should find the values there.
Once you delete those rows try
Code:
Private Sub CommandButton1_Click()
   Application.ScreenUpdating = False
   ActiveWorkbook.Sheets("OUT").Activate
   Range("AC5").Value = 1
   Range("AO" & Rows.Count).End(xlUp).Offset(1).Resize(, 3).Value = Array(Calendar1.Value, TextBox1.Value, TextBox2.Value)
   Range("AC5").Value = 0
   Range("AB4").Select
   Application.ScreenUpdating = True
End Sub
 
Upvote 0
In that case check the very last row of your sheet, you should find the values there.
Once you delete those rows try
Code:
Private Sub CommandButton1_Click()
   Application.ScreenUpdating = False
   ActiveWorkbook.Sheets("OUT").Activate
   Range("AC5").Value = 1
   Range("AO" & Rows.Count).End(xlUp).Offset(1).Resize(, 3).Value = Array(Calendar1.Value, TextBox1.Value, TextBox2.Value)
   Range("AC5").Value = 0
   Range("AB4").Select
   Application.ScreenUpdating = True
End Sub
Thank you Fluff , will give it a go tomorrow
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top