Visual basic functions

B

Brett

I'm very new to this area of Excel (i'm still studying at school) and i was
wondering if anyone could help me with some code to help me.

what i want to accomplish is to delete data in cells G3:G12 but i want it do
only be deleted when new information is entered into Cell E1. I also want to
be able to add values to Cells G3:G12 before they get deleted, and then be
able to add values afterward,

Thank you in advance, if anymore information is required, please specify and
i will do my best.
 
J

Jacob Skaria

Hi Brett

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.




Dim varTemp As Variant

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("E1")) Is Nothing Then
If varTemp <> Target Then Range("G3:G12").ClearContents
varTemp = Range("E1")
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
 
B

Brett

Thank you very much! i have been trying so many things haha.

Pecoflyer, it is not necessarily homework, it's like a practice project
where we try to learn how to use new functions, and i wanted to learn how to
do this one.
 

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

Top