anubis
Active Member
- Joined
- Dec 22, 2004
- Messages
- 359
Hi all,
First, a little background info for everyone...
1. I am trying to teach myself VBA (via this board and a J. Walkenbach book). So the code may be messy... :wink:
2. Cells A6:D6 are merged and hardcoded with text.
3. The following cells are merged and filled with text via a userform...
a. E6:K6
b. N6:T6
c. W6:AC
d. AF6:AL6
e. AO6:AU6
4. The following cells are filled with numbers via the above mentioned userform...
a. L6
b. U6
c. AD6
d. AM6
e. AV6
I am trying to determine the last cell that has a number in it in the range of A6:AV6. There will never be an instance where the last cell is filled with text. I am using the following code to find the last filled cell (always a number) and depending on the result, call a module (routine? I don't know the correct term).
I am using this code in another userform, and it is working fine. However, in this userform it keeps returning U6 as the last cell with a number when the last cell is L6.
Any suggestions, as always, would be greatly appreciated.
EDIT: I forgot... I used =CELL("address",INDEX(E6:AV6,MATCH(BigNum,E6:AV6,1))) on the sheet and it returned the correct cell...L6 Just one more reason I'm going nuts with this.
First, a little background info for everyone...
1. I am trying to teach myself VBA (via this board and a J. Walkenbach book). So the code may be messy... :wink:
2. Cells A6:D6 are merged and hardcoded with text.
3. The following cells are merged and filled with text via a userform...
a. E6:K6
b. N6:T6
c. W6:AC
d. AF6:AL6
e. AO6:AU6
4. The following cells are filled with numbers via the above mentioned userform...
a. L6
b. U6
c. AD6
d. AM6
e. AV6
I am trying to determine the last cell that has a number in it in the range of A6:AV6. There will never be an instance where the last cell is filled with text. I am using the following code to find the last filled cell (always a number) and depending on the result, call a module (routine? I don't know the correct term).
Code:
Private Sub CommandButton1_Click()
Dim Mk1 As String, Mk2 As String, MyColumn As Long
Mk1 = MkBox1.Text
If MkBox1.Text = "" Then
MsgBox "You Must Select One From Each Level."
Exit Sub
End If
Range("P126") = Mk1
Mk2 = MkBox2.Text
If MkBox2.Text = "" Then
MsgBox "You Must Select One From Each Level."
Exit Sub
End If
Range("P128") = Mk2
Unload MkAbilities1and2
MyColumn = Range("AW6").End(xlToLeft)
If Cells(6, MyColumn) = Range("A6") Then
Call More_Classes
Else
If Cells(6, MyColumn) = Range("L6") Then
Call Third_Classes
Else
If Cells(6, MyColumn) = Range("U6") Then
Call Fourth_Classes
Else
If Cells(6, MyColumn) = Range("AD6") Then
Call Fifth_Classes
Else
If Cells(6, MyColumn) = Range("AM6") Then
Demographics.Show
End If
End If
End If
End If
End If
End Sub
I am using this code in another userform, and it is working fine. However, in this userform it keeps returning U6 as the last cell with a number when the last cell is L6.
Any suggestions, as always, would be greatly appreciated.
EDIT: I forgot... I used =CELL("address",INDEX(E6:AV6,MATCH(BigNum,E6:AV6,1))) on the sheet and it returned the correct cell...L6 Just one more reason I'm going nuts with this.