VBA Code for Removing alphanumeric (i.e. Question3456321) like this in cell

sanjeetkr77

New Member
Joined
Nov 24, 2012
Messages
2
Hi ,

Well I m not VBA Code writer but need help on one problem.

Problem situation:-

Question22XXX (so any cell value ending with last 3 X / keep it)
Question2XXX (cell value with alphabet+Number+ 3 X/keep it)
Question80A (So any cell value mixture with alphabet+ Number+alphabets /keep it)
Question12345 (here , any cell value with alphabets +Number /Delete full row, assuming column "B")
1235234XXXXX (Delete all cell value with entire row, if its starts with number and ending more than 5 X in last)

Please help, to get some code as i have situation of thousands of data in such situation and , i got to manually drag down and deleting it . Thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi ,

Well I m not VBA Code writer but need help on one problem.

Problem situation:-

Question22XXX (so any cell value ending with last 3 X / keep it)
Question2XXX (cell value with alphabet+Number+ 3 X/keep it)
Question80A (So any cell value mixture with alphabet+ Number+alphabets /keep it)
Question12345 (here , any cell value with alphabets +Number /Delete full row, assuming column "B")
1235234XXXXX (Delete all cell value with entire row, if its starts with number and ending more than 5 X in last)

Please help, to get some code as i have situation of thousands of data in such situation and , i got to manually drag down and deleting it . Thanks

like this ??
Code:
Sub sanjee()
Dim lastrow As Long

lastrow = Range("A" & Rows.Count).End(xlUp).Row 'change "A" to column where your values are store

For i = lastrow To 1 Step -1
 cell = Cells(i, 1) 'change 1 to column where your values are stored 1 = A , B = 2 .........
    If IsNumeric(Right(cell, 1)) And Asc(Left(cell, 1)) >= 65 And Asc(Left(cell, 1)) <= 122 Or UCase(Right(cell, 5)) = "XXXXX" Then
    Cells(i, 1).EntireRow.Delete
    End If
    
Next i
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top