Match a string to a col & increment by 1
Solved/Closed
seema_gu14
-
Mar 30, 2010 at 09:39 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Mar 30, 2010 at 09:48 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Mar 30, 2010 at 09:48 PM
Related:
- Match a string to a col & increment by 1
- Tentacle locker 1 - Download - Adult games
- Igi 1 download - Download - Shooters
- Fnia 1 apk - Download - Adult games
- Music match jukebox - Download - Audio playback
- Fnaf 1 download pc - Download - Horror
1 response
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Mar 30, 2010 at 09:48 PM
Mar 30, 2010 at 09:48 PM
I have added one more data in A3 in sheet 1
B0102
in sheet 2 row is column headings and data is below
string
A0101001
B0102001
Q9911001
S7834001
A0101002
A0101003
then try this macro"test". If you want to recheck first run mcaro "undo" and then "test"
B0102
in sheet 2 row is column headings and data is below
string
A0101001
B0102001
Q9911001
S7834001
A0101002
A0101003
then try this macro"test". If you want to recheck first run mcaro "undo" and then "test"
Sub test()
Dim r As Range, c As Range, x As String
Dim j As Integer, cfind As Range
Dim y As String, add As String
j = 0
With Worksheets("sheet1")
Set r = Range(.Range("A2"), .Range("A2").End(xlDown))
'msgbox r.Address
For Each c In r
x = c.Value
With Worksheets("sheet2")
Set cfind = .Cells.Find(what:=x, lookat:=xlPart)
If cfind Is Nothing Then GoTo nnext
j = j + 1
add = cfind.Address
'msgbox j
'msgbox add
Do
Set cfind = .Cells.FindNext(cfind)
If cfind Is Nothing Then GoTo nnext
If cfind.Address = add Then GoTo line1
'msgbox cfind.Address
j = j + 1
'msgbox j
Loop
line1:
y = Mid(cfind, 6, 2)
End With 'sheet2
c.Offset(0, 1) = x & y & j + 1
nnext:
j = 0
Next c
End With
End Sub
Sub undo()
With Worksheets("sheet1")
Range(.Range("B2"), .Range("B2").End(xlDown)).Clear
End With
End Sub