Consulting

Results 1 to 3 of 3

Thread: Generate an table Index

  1. #1
    VBAX Regular
    Joined
    Dec 2015
    Posts
    7
    Location

    Generate an table Index

    Hi, i need an urgent help plz! im having problems (cause im an ignorant in VBA and macros) modifiying this macro:
    Encabezadosconcambiodatos1.xlsm
    What i need to do is change the table where the macro gets the information, those are [A3:A5] and [B3:B5].
    the cells that i really want to get the information are: [A4:A6] and [B4:B6].
    i know it sound silly but ive been like 2 hours trying to find the solution but i cant because i dont know programming :´(
    please help me its very important

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,710
    Location
    This one?
    Public Sub CrearEncabezamiento()
    Dim Columna As Integer
    Application.ScreenUpdating = False
    FormatearEncabezado
    Columna = 11
    For x = 3 To Hoja1.Range("A" & Rows.Count).End(xlUp).Row
       For y = 1 To Hoja1.Range("A" & x)
          If Columna > 1 Then Hoja1.Range("K1:N3").Copy Hoja1.Cells(1, Columna)
          Hoja1.Cells(1, Columna) = "Camión " & y & Hoja1.Range("B" & x)
          Columna = Columna + 4
       Next
    Next
    Hoja1.Select
    End Sub
    See if I got this right
    Public Sub CrearEncabezamiento()
    'For help see: http://www.vbaexpress.com/forum/showthread.php?54672-Generate-an-table-Index
    
    Dim rngCantidad As Range
    Dim Columna As Long
    Const finaCantidadRow As Long = 6
    'Alternative: to use all Cantidadas (more than A4:A6)
    'Dim finaCantidadRow as long
    ' finaCantidad = Sheets("Hoja1").Cells(Rows.Count, 1).End(xlUp).Row
    
    Application.ScreenUpdating = False
    FormatearEncabezado
    
    With Sheets("Hoja1")
    Set rngCantidad = .Range("A4") 'First Cantidad
    
    'From first Camion Column to last Camion Column stepping 4 columns at a time
    For Columna = 11 To .Cells(1, Columns.Count).End(xlToLeft).Column Step 4
       .Cells(1, Columna) = "Camión " & rngCantidad & rngCantidad.Offset(0, 1)
       
       'Move cantidad Range down one Row
       Set rngCantidad = rngCantidad.Offset(1)
       If rngCantidad.Row = finaCantidadRow Then Exit For
    Next
    End With
    
    Application.ScreenUpdating = True
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Dec 2015
    Posts
    7
    Location
    Thank for the help!

Posting Permissions

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