Ayuda con una macro

hopkin

New Member
Joined
Oct 24, 2013
Messages
1
Hola a todos,

Tengo creada una macro para que me muestre de la pestaña de resumen los importes conseguidos de rappel por una tienda para cada proveedor, haciendo doble click en la tienda, el problema es que no consigo que me muestre los datos y sólo aparecen las celdas en blanco, si alguien me puede ayudar lo agradecería!

La Macro es:
Code:
Option Explicit
    Dim tienda As String
    Dim producto As String
    Dim fila1 As Integer
    Dim fila_fin As Integer
    Dim num_prov As Integer
    Dim i As Integer, j As Integer



    Sub proveedores()
       
        'miramos la tienda y el producto elegidos
        tienda = ActiveCell.Value
        If tienda = "" Then GoTo error
       
        Do While Not IsEmpty(ActiveCell)
            ActiveCell.Offset(-1, 0).Select
        Loop
        producto = ActiveCell.Offset(-1, 0).Value
       
        'creamos la nueva hoja con el nombre adecuado
        Sheets.Add After:=Sheets(Sheets.Count)
        ActiveSheet.Name = tienda & "-" & producto
        Cells(1, 1) = producto
        Cells(2, 1) = tienda
       
        'buscamos los datos para copiarlos en la hoja creada
        Sheets(producto).Select
        num_prov = 0
        Cells.Find(What:=tienda, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
        fila1 = ActiveCell.Row
        Cells.FindNext(After:=ActiveCell).Activate
        fila_fin = ActiveCell.Row
        num_prov = 1
        Do While fila_fin <> fila1
            Cells.FindNext(After:=ActiveCell).Activate
            fila_fin = ActiveCell.Row
            num_prov = num_prov + 1 'contamos el numero de proveedores
        Loop
       
        For i = 0 To num_prov - 1
            If i > 0 Then
                Cells.Find(What:=tienda, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
                :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                False, SearchFormat:=False).Activate
            End If
            For j = 1 To i
               Cells.FindNext(After:=ActiveCell).Activate
            Next j
           
            Do While Not IsEmpty(ActiveCell)
                ActiveCell.Offset(-1, 0).Select
            Loop
            ActiveCell.Offset(1, 0).Copy
       
            Sheets(tienda & "-" & producto).Select
            Cells(1, 2 + i).Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
            Application.CutCopyMode = False
       
            Sheets(producto).Select
        Next i
        Sheets(tienda & "-" & producto).Select
error:
        If tienda = "" Then MsgBox ("Elige una celda no vacía")

    End Sub
 
Last edited by a moderator:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,223,948
Messages
6,175,569
Members
452,652
Latest member
eduedu

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