column number in VB

dark11984

New Member
Joined
Sep 9, 2008
Messages
10
Hi,
I am trying to find the column number of cell(1,j) if j is equal to a month/year selected in a combo box.

Thanks,
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try:
Code:
Private Sub ComboBox1_Click()
j = ComboBox1.ListIndex
Cells(1, j + 1).Select
End Sub
 
Upvote 0
Sorry not quite what i was looking for, i probably should've explained it a bit better. We currently run a macro each month but it has only been setup to run this FY and will run out next month.

So i am trying to write a new code that we will be able to use going forward without having to amend each FY.

This is the current code:
Code:
Sub ProcessData()
'
    Dim Cl08 As Integer
    Dim Msb As Integer
    Dim Month As Variant
 
    CopyFailuresToCalculations
 
    Sheets("Instructions").Select
 
    Month = Cells(26, 3)
 
    Cl08 = 87 'Starting column number for Year 2008
 
    Select Case Month
 
        'Starts from Jul 09 to Jun 10 ONLY !!!
 
        Case "Jul 09"
            CopyCalculationsToLRAudits (Cl08 + 2)
 
        Case Is = "Aug 09"
            CopyCalculationsToLRAudits (Cl08 + 4)
 
        Case "Sep 09"
            CopyCalculationsToLRAudits (Cl08 + 6)
 
        Case "Oct 09"
            CopyCalculationsToLRAudits (Cl08 + 8)
 
        Case "Nov 09"
            CopyCalculationsToLRAudits (Cl08 + 10)
 
        Case "Dec 09"
            CopyCalculationsToLRAudits (Cl08 + 12)
 
        Case "Jan 10"
            CopyCalculationsToLRAudits (Cl08 + 14)
 
        Case "Feb 10"
            CopyCalculationsToLRAudits (Cl08 + 16)
 
        Case "Mar 10"
            CopyCalculationsToLRAudits (Cl08 + 18)
 
        Case "Apr 10"
            CopyCalculationsToLRAudits (Cl08 + 20)
 
        Case "May 10"
            CopyCalculationsToLRAudits (Cl08 + 22)
 
        Case "Jun 10"
            CopyCalculationsToLRAudits (Cl08 + 24)
 
    End Select
    Application.CutCopyMode = False
    Sheets("Instructions").Select
    Cells(30, 1).Select
 
    Msb = MsgBox("LR audits have been successfully processed !", vbOKOnly)
End Sub

This is the new code i am workign on and i can't get it to work.

Code:
Sub ProcessData_New()
    
    Dim Msb As Integer
    Dim Month As Variant
    
    CopyFailuresToCalculations
    
    Sheets("Instructions").Select
    
    Month = Cells(26, 3)
    
    Dim j As Integer
    Dim ColumnCount As Integer
    
    j = 1
    ColumnCount = Cells(1, j).Value
    
    Do While Cells(2, j).Value <> ""
        If Cells(2, j).Value = Month Then
            CopyCalculationsToLRAudits (ColumnCount + 1)
               
            
        Else
            Msb = MsgBox("failed !", vbOKOnly)
        End If
    j = j + 1
    Loop
            
Msb = MsgBox("LR audits have been successfully processed !", vbOKOnly)
End Sub

Any help would be much appreciated.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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