![]() |
Visual basic functions
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. |
Visual basic functions
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 --------------- Jacob Skaria "Brett" wrote: 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. |
Visual basic functions
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. "Jacob Skaria" wrote: 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 --------------- Jacob Skaria "Brett" wrote: 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. |
All times are GMT +1. The time now is 03:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com