Home > Software engineering >  Rookie help VBA code
Rookie help VBA code

Time:10-05




Click refresh, and the red areas, according to the rules of the above arrangement, please master to write a few lines of VBA code, thank you ~!

CodePudding user response:

 Sub Test () 
Dim arr, BRR, i& J& N&
Arr=[a1]. Resize ([a65536]. End (3). The Row, 6)
ReDim BRR (UBound (arr), 1)
BRR (0, 0)="date"
BRR (0, 1)="name"
For I=2 To UBound (arr)
For j=2 To 6
If arr (I, j) & gt; "" Then n=n + 1: BRR (n, 0)=arr (I, 1) : BRR (n, 1)=arr (1, j)
Next j, I
[i1]. Resize (n + 1, 2)=BRR
MsgBox "OK"
End Sub

CodePudding user response:

Dim arr, BRR, i& J& N& What is the meaning of this sentence?

CodePudding user response:

refer to the second floor pangmp1234 response:
Dim arr, BRR, i& J& N& What is the meaning of this sentence?

Array is written on it, the building Lord, basic knowledge to understand, if you don't understand that others have written, have a purpose, not flexible
Write a simple show you the

 
Sub (aa)
Dim hang As Integer variables' wrote how many rows
Dim a As Integer variables'
Dim b As Integer variables'
Dim I As Integer '
how many lines need to decideDim j As Integer 'need to decide how many column
Hang=2 'default write starting act 2, where is the need to write the starting number of rows

I=Range (" a65536 "). The End (xlUp). Row 'need determine how many lines for
J=InputBox (" input how many columns ")
'2 loops, solve the problem of you
For a=2 To I "starting behavior in the second row
For b=2 To j 'starting as the second column
If the Trim (Cells (a, b)) & lt;> "" Then 'inline is not equal to null, automatically writes the name and the date specified location
Cells (hang, 9)=Cells (a, 1) 'write the date in column I
Cells (hang, 10)=Cells (1 b) 'write name in J column
Hang hang=write done automatically add 1 + 1 '
End the If
Next
Next
End Sub
'such a structure, you should see the understand??

CodePudding user response:

Very simple idea:
 Private Sub CommandButton1_Click () 
Dim As Long, I k, As Long As Long j
K=2 'initial line number
For I=2 To Cells. The Rows. The Count 'starting line 2 check
If the Trim (Cells (I, 1))="" Then Exit the For 'found the content of the column 1 is empty retreat to cycle
For j=2 To 6 ' 'from the second column To column 6
If the Trim (Cells (I, j)) & lt;> "" Then" not null start recording
Cells (k, 9)="'" & amp; Cells (I, 1) 'add date
Cells (k, 10)=Cells (1, j) "' add name
K=k + 1 + 1
'line numberEnd the If
Next
Next
End Sub
  •  Tags:  
  • VBA
  • Related