Hi all,
Wonder if someone might be able to give me a steer on a little problem i am having. I need to clear the contents of a cell, but which cell is emptied depends on the value selected by the user - or more specifically two cells.
As an example, i have three columns of numbers, C, E, & G. these are all unique numbers.
The user then has two drop down boxes in A1 and A2. The first lets the user select what type of numer they want to get rid of - falling into either the set in C, E or G.
The second dropdown then lists all of the numbers in that given column. Once the user selects what number they wish to remove there is a button which they can press and will go find that number and remove it (plus some other information relevant to that number.
The problem is i can't get VBA to specify which column to look in (based on the contents selected by the user in the first drop down.
I was trying to define the columns and rows as j & k - so for example this would give me the following peice of code:
This should find out if it is the bottom value in the list and if so remove the value (the code has two parts - the second says if it's not the last value in the list then it moves the other numbers up - to maintain a list without gaps).
The problem i have is trying to get k to be variabel based on the contents of cell A1. I tried to use the following:
But i'm not sure that is doing what i want it to, or what the best way to get around this problem would be. If anyone could give me a steer in the right direction i would be very very appreciative.
Thanks in advance for any ideas.
Wayner
Wonder if someone might be able to give me a steer on a little problem i am having. I need to clear the contents of a cell, but which cell is emptied depends on the value selected by the user - or more specifically two cells.
As an example, i have three columns of numbers, C, E, & G. these are all unique numbers.
The user then has two drop down boxes in A1 and A2. The first lets the user select what type of numer they want to get rid of - falling into either the set in C, E or G.
The second dropdown then lists all of the numbers in that given column. Once the user selects what number they wish to remove there is a button which they can press and will go find that number and remove it (plus some other information relevant to that number.
The problem is i can't get VBA to specify which column to look in (based on the contents selected by the user in the first drop down.
I was trying to define the columns and rows as j & k - so for example this would give me the following peice of code:
Code:
For j = 4 To 205
If Cells(j, k + 1) = Range("$A$2") And Cells(j + 1, k) = 0 Then
Cells(j, k).ClearContents
This should find out if it is the bottom value in the list and if so remove the value (the code has two parts - the second says if it's not the last value in the list then it moves the other numbers up - to maintain a list without gaps).
The problem i have is trying to get k to be variabel based on the contents of cell A1. I tried to use the following:
Code:
If Range("$A$1") = "Supergroup" Then k = 3
If Range("$A$1") = "Group" Then k = 5
If Range("$A$1") = "Upcs" Then k = 7
But i'm not sure that is doing what i want it to, or what the best way to get around this problem would be. If anyone could give me a steer in the right direction i would be very very appreciative.
Thanks in advance for any ideas.
Wayner