help with char(160)+password vba

avishain

Board Regular
Joined
Dec 14, 2010
Messages
75
Hello all,

i need help with the following issue:

im using excel 2007,however,the spesific file is XLS (excel 2003).

got a table from A:K.

in columns A and J ,i got numbers which are formated as "General" and i want to keep it that way.
in some cases,the data has char(160) at the begining and i want to fix it.

now,i can use a function like TRIM(A1) or SUBSTITUTE($A1,CHAR(160),"")
but i want to use VBA .

another thing,

this sheet contains a pasword ("1234") ,so i want to assian a button and when i click it ,it will :

1.unlock the sheet with the password (1234)
2.remove from column A and J the char(160) or any space at the begining.
3.put a password again (1234).

thank u for helping.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Code:
Sub AJ_Trimmer()
    
    ActiveSheet.Unprotect Password:="1234"
                    
    Range("A:A, J:J").Replace Chr(160), "", xlPart
    Range("A:A, J:J").Replace " ", "", xlPart
    
    ActiveSheet.Protect Password:="1234"
    
End Sub
 
Upvote 0
Code:
Sub AJ_Trimmer()
 
    ActiveSheet.Unprotect Password:="1234"
 
    Range("A:A, J:J").Replace Chr(160), "", xlPart
    Range("A:A, J:J").Replace " ", "", xlPart
 
    ActiveSheet.Protect Password:="1234"
 
End Sub



it works partialy...

in some cases there is a space.... i tried the trim function and it helped.

can u give me a code to use the trim function on the same range? (A and J) and in addition, to paste it as values...

?

thanks
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,283
Members
452,902
Latest member
Knuddeluff

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