Hello! I'm really struggling with this issue using VBA in Excel. For starters, I'm no expert in Excel, but I'm trying my best with a really complex issue applying VLookup. I'll detail the issue with images below:
This is what I have until now. However, all it does is look for a letter in my separate sheet and turn it into a value and delete any rows that have a number lower than the letter's value. Its not at all what I want.
I appreciate any help.
- I have a table that associates code letters to numbers in a separate sheet. I did that because I need a method to quantify these letters so I may later compare them. They do not work in alphabetical order.
- With this table (In the separate sheet), I intend to allow the user to insert a table with many "products" that have a code assigned to them (the codes are composed of a combination of numbers and letters. Ex: 91V). Then, the user will run a macro and insert a new code. The inserted code will be used by the macro do compare with the other codes in the table and any given row with a code composed by larger numbers than the onde input by the user or a letter with a lower value, will be deleted. Example of a table inserted by the user:
This is what I have until now. However, all it does is look for a letter in my separate sheet and turn it into a value and delete any rows that have a number lower than the letter's value. Its not at all what I want.
Code:
<code style="white-space: inherit; margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif;">[COLOR=#101094]Sub[/COLOR][COLOR=#303336] DeletarIndices[/COLOR][COLOR=#303336]()[/COLOR][COLOR=#303336]
indice [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] InputBox[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"Digite o Valor Desejado"[/COLOR][COLOR=#303336],[/COLOR][COLOR=#7D2727]"Teste"[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Set[/COLOR][COLOR=#303336] planilhaV [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] Sheets[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"IV"[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Dim[/COLOR][COLOR=#303336] vValores [/COLOR][COLOR=#101094]As[/COLOR][COLOR=#101094]String[/COLOR][COLOR=#303336]
sResult [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] Application[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]VLookup[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336]indice[/COLOR][COLOR=#303336],[/COLOR][COLOR=#303336] planilhaV[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Range[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"A2:B11"[/COLOR][COLOR=#303336]),[/COLOR][COLOR=#7D2727]2[/COLOR][COLOR=#303336])[/COLOR][COLOR=#303336]
Application[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]ScreenUpdating [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#7D2727]False[/COLOR][COLOR=#303336]
Application[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Calculation [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] xlCalculationManual
[/COLOR][COLOR=#101094]Dim[/COLOR][COLOR=#303336] i [/COLOR][COLOR=#101094]As[/COLOR][COLOR=#101094]Long[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]For[/COLOR][COLOR=#303336] i [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] Range[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"A"[/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] Rows[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Count[/COLOR][COLOR=#303336]).[/COLOR][COLOR=#101094]End[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336]xlUp[/COLOR][COLOR=#303336]).[/COLOR][COLOR=#303336]Row [/COLOR][COLOR=#101094]To[/COLOR][COLOR=#7D2727]1[/COLOR][COLOR=#101094]Step[/COLOR][COLOR=#303336]-[/COLOR][COLOR=#7D2727]1[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]If[/COLOR][COLOR=#101094]Not[/COLOR][COLOR=#303336]([/COLOR][COLOR=#303336]Range[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"A"[/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] i[/COLOR][COLOR=#303336]).[/COLOR][COLOR=#303336]Value [/COLOR][COLOR=#303336]>[/COLOR][COLOR=#303336] sResult[/COLOR][COLOR=#303336])[/COLOR][COLOR=#101094]Then[/COLOR][COLOR=#303336]
Range[/COLOR][COLOR=#303336]([/COLOR][COLOR=#7D2727]"A"[/COLOR][COLOR=#303336]&[/COLOR][COLOR=#303336] i[/COLOR][COLOR=#303336]).[/COLOR][COLOR=#303336]EntireRow[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Delete
[/COLOR][COLOR=#101094]End[/COLOR][COLOR=#101094]If[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]Next[/COLOR][COLOR=#303336] i
Application[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]Calculation [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#303336] xlCalculationAutomatic
Application[/COLOR][COLOR=#303336].[/COLOR][COLOR=#303336]ScreenUpdating [/COLOR][COLOR=#303336]=[/COLOR][COLOR=#7D2727]True[/COLOR][COLOR=#303336]
[/COLOR][COLOR=#101094]End[/COLOR][COLOR=#101094]Sub[/COLOR]</code>
I appreciate any help.