首页->【软件工具包使用(SW/Software Tools Usage)】

5 1

'Dsn:Winyoo_shiy

'Location:Shanghai,PRC

'ReleaseDate:10/14/18

Public Sub AutoFill()

   Dim StartPosition As Integer

   Dim EndPosition   As Integer

   Dim CustomerName(697) As String

   Dim CustomerInfo(697) As String

   Dim i As Integer

   

   'Dim CustomerInfoCol As Integer

   i = 0

   Sheet2.Activate

   StartPosition = 2

   EndPosition = 699

   For cnti = StartPosition To EndPosition

         With Sheet2

            CustomerName(i) = .Cells(cnti, 1).Value

            i = i + 1

         End With

   Next cnti

 

Sheet1.Activate

For i = 0 To 697

    With ActiveSheet.Cells

        Set c = .Find(CustomerName(i), , , xlWhole, xlByColumns, xlNext, False)

        If Not c Is Nothing Then

                p = c.Address

                CellRow = c.Row

                CellCol = c.Column

                Do

                    'c.Interior.ColorIndex = 4

                    q = q & c.Address & vbCrLf

                    Set c = .FindNext(c)

                Loop While Not c Is Nothing And c.Address <> p

           

    With Sheet1

                CustomerInfo(i) = .Cells(CellRow, CellCol + 1).Value

    End With

 

           End If

End With


Next i

        

'CustomerInfoCol = 2

Sheet2.Activate

With Sheet2

    .Range("B2:B699").Select

     For cnti = StartPosition To EndPosition

        .Cells(cnti, 2).Value = CustomerInfo(cnti - 2)

    Next cnti

End With

     

End Sub


作者于2018-10-14 11:26:44修改!
楼主可见

  1. shwnyoo 1#

    ***此内容已隐藏,只有楼主可见***