Results 1 to 10 of 10

Thread: Numbered column in vba

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Senior Member
    Join Date
    Oct 2011
    Posts
    135
    Rep Power
    14
    Hi,

    I messed around a bit 'to run in a loop vba.
    I wonder if you can better manage this cycle with an array

    Code:
    Option Explicit
    Public Const RigaUp = 2
    
    Sub a()
        Dim RigaDn As Long
        Dim Giorni As Variant
        Dim ciclo As Long
        Dim ciclo1 As Long
        Dim start As Integer
        Dim Old As Integer
        RigaDn = Cells(Rows.Count, 1).End(xlUp).Row
        Giorni = Range(Cells(RigaUp, 4), Cells(RigaDn, 5)).Value
        For ciclo = 1 To UBound(Giorni)
            Giorni(ciclo, 1) = Int(Giorni(ciclo, 1))
        Next
        Range("AA2:AA21") = Giorni
        For ciclo1 = 1 To UBound(Giorni)
            Cells(ciclo1 + 1, 28) = Contig(Range("AA" & ciclo1 + 1 & ":AA22"), Int(Giorni(ciclo1, 1)))
        Next
    End Sub
    Code:
    Function Contig(ByRef Myaddr As Range, ByVal myVal As String) As Integer
    For Each cell In Myaddr
        If cell.Value = myVal Then
            ccnt = ccnt + 1
        Else
            If ccnt > Contig Then Contig = ccnt
            ccnt = 0
        End If
    Next cell
    End Function
    Last edited by PcMax; 07-01-2012 at 09:12 PM. Reason: Code Function Contig:

Similar Threads

  1. Replies: 10
    Last Post: 05-23-2013, 12:30 PM
  2. Replies: 6
    Last Post: 05-16-2013, 09:56 AM
  3. Numbered List Of Unique Values
    By xander1981 in forum Excel Help
    Replies: 6
    Last Post: 01-21-2013, 06:10 PM
  4. MS-Access Set Default Value of Column Using VBA
    By LalitPandey87 in forum Access Help
    Replies: 2
    Last Post: 04-08-2012, 09:40 AM
  5. Splittting Data Into Different Worksheets Column Wise In VBA
    By rajeshd@live.in in forum Excel Help
    Replies: 1
    Last Post: 01-21-2012, 04:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •