Locking panes

G

Guest

I have a macro that does alot of things in a spreadsheet. I want the code to
lock the panes at a certain column. The coulmn is not the same every time so
I cannot simply record a macro but if a record a macro the code is:

Columns("F:F").Select
ActiveWindow.FreezePanes = True

Now I need to replace the first line with something else. I want to lock the
panes where at the column where the word "Securitiy ID" is found. There (with
some help) I wrote:

Set rng2 = Worksheets("Beräkning").Cells.Find("Security ID", LookIn:=xlValues)
......
Columns(rng2.Address).Select
ActiveWindow.FreezePanes = True

but this does not work. Please help me if you have any clue. Thanks!
 
D

DAV135

Cells.Find(What:="Security ID", After:=ActiveCell,
LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate
Columns(ActiveCell.Column).Select
ActiveWindow.FreezePanes = True


*If that doesn't wory, check your spelling of Security, not sure if you
copied and pasted it but there was a spelling mistake!

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top