Hi
Thanks for the info.
I’ve created VBA and extract some data at some point. However, it stops at the statement (qusector = Left(Cells(i, 3), openbracketpos - 2)) when running to the cell C9 (534R4). I think there are blank cells below and can’t proceed. Please advise how to fix.
The purpose is to extract each category and split into text and percentage, eg MUG, 38.5; PLATE, 12.2...
Here is the original data
MUG (38.5%)
33,700 jaf
22,200 534R4
PLATE (12.2%)
31,900 wasd
88,000 fef
72,400 ve
5,800 vw
131,100 v
CUP (10.6%)
64,870 rwer
85,300 vasd
88,760 jytj
26,900 mjk
54,800 mhg
66,600 dhfg
and here is the code:
Sub copypastecolumndata()
Dim i As Integer
Dim j As Integer
Dim qusector As String
Dim quper As String
Dim lastrow As Long
Dim openbracketpos As Integer
Dim closebracketpos As Integer
Dim lrow As Integer
Sheet3.Select
Sheet3.Cells.ClearContents
Range("a1") = "Sectors"
Range("b1") = "Percent"
Sheet1.Select
lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For i = 7 To lastrow
openbracketpos = InStr(Cells(i, 3), "(")
closebracketpos = InStr(Cells(i, 3), ")")
If Cells(i, 3) = UCase(Cells(i, 3)) Then
qusector = Left(Cells(i, 3), openbracketpos - 2)
lrow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet3.Cells(lrow, 1) = qusector
If Cells(i, 3) = UCase(Cells(i, 3)) Then
quper = Mid(Cells(i, 3), (openbracketpos + 1), (closebracketpos - openbracketpos - 2))
Sheet3.Cells(lrow, 2) = quper
End If
End If
Next i
End Sub