Sub kTest()
Dim a, v, i As Long, w()
a = Range("A1").CurrentRegion.Resize(, 1)
ReDim w(1 To UBound(a, 1), 1 To 1)
For Each v In a
If UCase(Left$(v, 1)) = "A" Then 'if the first letter is A
i = i + 1
w(i, 1) = v
End If
Next
With Sheets("Sheet2").Range("a1")
.Resize(i).Value = w
End With
End Sub
Hi,
May be..
Code:Sub kTest() Dim a, v, i As Long, w() a = Range("A1").CurrentRegion.Resize(, 1) ReDim w(1 To UBound(a, 1), 1 To 1) For Each v In a If UCase(Left$(v, 1)) = "A" Then 'if the first letter is A i = i + 1 w(i, 1) = v End If Next With Sheets("Sheet2").Range("a1") .Resize(i).Value = w End With End Sub
Sub kTest()
Dim a, i As Long, w(), n As Long, c As Long
a = Range("A1").CurrentRegion.Resize(, 3) '3 columns
ReDim w(1 To UBound(a, 1), 1 To 3)
For i = 1 To UBound(a, 1)
If UCase(Left$(a(i, 1), 1)) = "A" Then 'if the first letter is A
n = n + 1
For c = 1 To 3: w(n, c) = a(i, c): Next
End If
Next
With Sheets("Sheet2").Range("a1")
.Resize(n, 3).Value = w
End With
End Sub
Hi,
HTHCode:Sub kTest() Dim a, i As Long, w(), n As Long, c As Long a = Range("A1").CurrentRegion.Resize(, 3) '3 columns ReDim w(1 To UBound(a, 1), 1 To 3) For i = 1 To UBound(a, 1) If UCase(Left$(a(i, 1), 1)) = "A" Then 'if the first letter is A n = n + 1 For c = 1 To 3: w(n, c) = a(i, c): Next End If Next With Sheets("Sheet2").Range("a1") .Resize(n, 3).Value = w End With End Sub
Sub kTest()
Dim a, i As Long, w(), n As Long, c As Long
a = Range("A1").CurrentRegion.Resize(, 7) '7 columns
ReDim w(1 To UBound(a, 1), 1 To 7)
For i = 1 To UBound(a, 1)
If UCase(Left$(a(i, 1), 1)) = "K" Then 'if the first letter is A
n = n + 1
For c = 1 To 7: w(n, c) = a(i, c): Next
End If
Next
If n > 0 Then
With Sheets("Sheet2").Range("a1")
.Resize(n, 7).Value = w
End With
Else
MsgBox "No record found", vbInformation
End If
End Sub