Home > Software engineering >  Vba: object the require
Vba: object the require

Time:09-28

 Sub Macro3 () 
'
'Macro3 Macro
'

'
Dim the ws As Worksheet
Dim rr As Worksheet
On the Error Resume Next
Set the ws=Worksheets (" sheet4 ")
The Set of rr=ActiveSheet
If Err Then
Sheets. The Add
ActiveSheet. Name="sheets4
"End the If


Dim I As an Integer, j As Integer
I=3
J=1
Dim r As an Integer, c As Integer
Dim st As String
R=1

The rr. Select
With rr. Range (" a1: q500 ")
The Set c=Cells. The Find (Breaker "No.", LookIn:=xlValues)
If Not c Is Nothing Then
Firstaddress=c.a. ddress
Do
J=1
St=Cells (Selection. Row - 2, Selection. The Column + j). The Value
Do
I=3
C=2
Cells (Selection. Row Selection. The Column + 1). Copy
Sheets (" sheet4 "). Select
1, Cells (r) Value=https://bbs.csdn.net/topics/st
Cells (r, c). Paste
The rr. Select
C.s. well
Do
C=c + 1
Cells (Selection. Row + I, sellection. Column + j). Copy
Sheets (" sheet4 "). Select
Cells (r, c). Paste
The rr. Select
C.s. well
I=I + 1
Loop While I & lt; 11.
J=j + 1
R=r + 1
Loop While j & lt; 13
The Set c=. FindNext (c)
Loop While Not c Is Nothing And c.a. ddress & lt;> Firstaddress
End the If
End With




End Sub




The above code in the Set c=Cells. The Find (" Breaker No. ", LookIn:=xlValues)
It is always the object the require of mistake, this is why
Pray god help!

CodePudding user response:


The type of variable c is wrong!
The Set c=Cells. The Find (Breaker "No.", LookIn:=xlValues)
Execute the code that c is belong to the "object" type of variables, and variables defined before you, c As Integer
Obviously can't successfully!

This code, you are recording macros and then modified by hand!
According to the back part of your code, c and there is need to use numerical class variables,
You can't put the logic reason clear point, and define the type of an Object type or Range of variables, use in the respective place???????

  •  Tags:  
  • VBA
  • Related