Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Freezing the top line of a sheet with visual basic
Hi;
I have a workbook with three sheets - Search Form, Results and Data Table. The search form allows the user to type in information into one of ten fields. Each field is aasociated with a column in the data table ; any hits go into the results sheet. The header row of the data table goes in as the top row of the results sheet. I'd like to freeze the results top row so that when someone scrolls through, the top row stays on top so the user can see the column descriptions. Also. I'd like to have the header row of the results sheet print out no matter where the user has scrolled to. I saw the following code in another post but it gave me a "run-time error 9: subscript out of range" error; the second line was indicated as the culprit: Worksheets("Sheet3").Activate Sheet3.Range("A1:J1").Select ActiveWindow.FreezePanes = True Any help is greatly appreciated. -- JJFJR |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Freezing the top line of a sheet with visual basic
Sheet3.Range("A1:J1").Select
This will give an error if there is no worksheet with codename "Sheet3". Note the codename can be distinct from the name on the sheet tab. Maybe try activeworkbook.sheets("Sheet3").Range("A1:J1").Sel ect or thisworkbook.sheets("Sheet3").Range("A1:J1").Selec t depending on where your code is running. Tim -- Tim Williams Palo Alto, CA "jjfjr" wrote in message ... Hi; I have a workbook with three sheets - Search Form, Results and Data Table. The search form allows the user to type in information into one of ten fields. Each field is aasociated with a column in the data table ; any hits go into the results sheet. The header row of the data table goes in as the top row of the results sheet. I'd like to freeze the results top row so that when someone scrolls through, the top row stays on top so the user can see the column descriptions. Also. I'd like to have the header row of the results sheet print out no matter where the user has scrolled to. I saw the following code in another post but it gave me a "run-time error 9: subscript out of range" error; the second line was indicated as the culprit: Worksheets("Sheet3").Activate Sheet3.Range("A1:J1").Select ActiveWindow.FreezePanes = True Any help is greatly appreciated. -- JJFJR |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Freezing the top line of a sheet with visual basic
Hi jjfjr! I tried the code you gave below and it didn't issue an error. But, it froze the wrong panes - the panes above and to the left of cell G18. If you want to freeze rows and/or columns, select the cell directly below the specified rows and to the right of the specified columns. Example, if you want to freeze row 1 and column A, you select, cell B2, which is directly below row 1 and to the right of column A. Then, FREEZE! Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("B2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; I have a workbook with three sheets - Search Form, Results and Data Table. The search form allows the user to type in information into one of ten fields. Each field is aasociated with a column in the data table ; any hits go into the results sheet. The header row of the data table goes in as the top row of the results sheet. I'd like to freeze the results top row so that when someone scrolls through, the top row stays on top so the user can see the column descriptions. Also. I'd like to have the header row of the results sheet print out no matter where the user has scrolled to. I saw the following code in another post but it gave me a "run-time error 9: subscript out of range" error; the second line was indicated as the culprit: Worksheets("Sheet3").Activate Sheet3.Range("A1:J1").Select ActiveWindow.FreezePanes = True Any help is greatly appreciated. -- JJFJR -- T-ョex ------------------------------------------------------------------------ T-ョex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=401601 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Freezing the top line of a sheet with visual basic
Hi;
Thanks for the response. I want to freeze the top row (header row) only...what do I select? I need all of the cells in the rest of the sheet to scroll. -- JJFJR "T-ツョex" wrote: Hi jjfjr! I tried the code you gave below and it didn't issue an error. But, it froze the wrong panes - the panes above and to the left of cell G18. If you want to freeze rows and/or columns, select the cell directly below the specified rows and to the right of the specified columns. Example, if you want to freeze row 1 and column A, you select, cell B2, which is directly below row 1 and to the right of column A. Then, FREEZE! Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("B2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; I have a workbook with three sheets - Search Form, Results and Data Table. The search form allows the user to type in information into one of ten fields. Each field is aasociated with a column in the data table ; any hits go into the results sheet. The header row of the data table goes in as the top row of the results sheet. I'd like to freeze the results top row so that when someone scrolls through, the top row stays on top so the user can see the column descriptions. Also. I'd like to have the header row of the results sheet print out no matter where the user has scrolled to. I saw the following code in another post but it gave me a "run-time error 9: subscript out of range" error; the second line was indicated as the culprit: Worksheets("Sheet3").Activate Sheet3.Range("A1:J1").Select ActiveWindow.FreezePanes = True Any help is greatly appreciated. -- JJFJR -- T-ツョex ------------------------------------------------------------------------ T-ツョex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=401601 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Freezing the top line of a sheet with visual basic
Hi! If you only want to freeze row 1, then you select cell A2. Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("A2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; Thanks for the response. I want to freeze the top row (header row) only...what do I select? I need all of the cells in the rest of th sheet to scroll. -- JJFJR "T-ツョex" wrote: Hi jjfjr! I tried the code you gave below and it didn't issue a error. But, it froze the wrong panes - the panes above and to the left o cell G18. If you want to freeze rows and/or columns, select the cell directly below the specified rows and to the right of the specified columns. Example, if you want to freeze row 1 and column A, you select, cel B2, which is directly below row 1 and to the right of column A. Then, FREEZE! Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("B2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; I have a workbook with three sheets - Search Form, Results an Data Table. The search form allows the user to type in information into one o ten fields. Each field is aasociated with a column in the data table any hits go into the results sheet. The header row of the data table goes i as the top row of the results sheet. I'd like to freeze the results to row so that when someone scrolls through, the top row stays on top so the use can see the column descriptions. Also. I'd like to have the header row o the results sheet print out no matter where the user has scrolled to. I saw the following code in another post but it gave me "run-time error 9: subscript out of range" error; the second line was indicated a the culprit: Worksheets("Sheet3").Activate Sheet3.Range("A1:J1").Select ActiveWindow.FreezePanes = True Any help is greatly appreciated. -- JJFJR -- T-ツョex ------------------------------------------------------------------------ T-ツョex's Profile http://www.excelforum.com/member.php...o&userid=26572 View this thread http://www.excelforum.com/showthread...hreadid=401601 -- T-ョe ----------------------------------------------------------------------- T-ョex's Profile: http://www.excelforum.com/member.php...fo&userid=2657 View this thread: http://www.excelforum.com/showthread.php?threadid=40160 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Freezing the top line of a sheet with visual basic
Hi;
I inserted the following code into my Search button code: Sheet3.Activate Sheet3.Range("A2").Select ActiveWindow.FreezePanes = True The Results sheets does freeze the top row, specifically cells A1 to J1. However, when I scroll, it seems that the entire area of A1 to J6 is frozen. Also, when I try to scroll horizontally, the entire columns A through E are also frozen. As I said before all I want frozen is the first row: cells A1 to J1. Before the above code is encountered, I clear out the first 1000 rows of the results sheet: Sheet3.Range("A2:J1000").ClearContents This is done to clear out the results from any previous searches. Also, just before the freeze code, I have the following code: Sheet3.Columns.AutoFit Sheet3.Rows.AutoFit This is done to reduce the area of the results sheet as much as possible. Any ideas? Any help is greatly appreciated. -- JJFJR "T-ツョex" wrote: Hi! If you only want to freeze row 1, then you select cell A2. Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("A2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; Thanks for the response. I want to freeze the top row (header row) only...what do I select? I need all of the cells in the rest of the sheet to scroll. -- JJFJR "T-テつョex" wrote: Hi jjfjr! I tried the code you gave below and it didn't issue an error. But, it froze the wrong panes - the panes above and to the left of cell G18. If you want to freeze rows and/or columns, select the cell directly below the specified rows and to the right of the specified columns. Example, if you want to freeze row 1 and column A, you select, cell B2, which is directly below row 1 and to the right of column A. Then, FREEZE! Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("B2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; I have a workbook with three sheets - Search Form, Results and Data Table. The search form allows the user to type in information into one of ten fields. Each field is aasociated with a column in the data table ; any hits go into the results sheet. The header row of the data table goes in as the top row of the results sheet. I'd like to freeze the results top row so that when someone scrolls through, the top row stays on top so the user can see the column descriptions. Also. I'd like to have the header row of the results sheet print out no matter where the user has scrolled to. I saw the following code in another post but it gave me a "run-time error 9: subscript out of range" error; the second line was indicated as the culprit: Worksheets("Sheet3").Activate Sheet3.Range("A1:J1").Select ActiveWindow.FreezePanes = True Any help is greatly appreciated. -- JJFJR -- T-テつョex ------------------------------------------------------------------------ T-テつョex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=401601 -- T-ツョex ------------------------------------------------------------------------ T-ツョex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=401601 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Freezing the top line of a sheet with visual basic
Hi jjfjr! I don't think it's possible to freeze just specific cells using FreezePanes. Sorry... I don't think I can help you with your problem... :( jjfjr Wrote: Hi; I inserted the following code into my Search button code: Sheet3.Activate Sheet3.Range("A2").Select ActiveWindow.FreezePanes = True The Results sheets does freeze the top row, specifically cells A1 to J1. However, when I scroll, it seems that the entire area of A1 to J6 is frozen. Also, when I try to scroll horizontally, the entire columns A through E are also frozen. As I said before all I want frozen is the first row: cells A1 to J1. Before the above code is encountered, I clear out the first 1000 rows of the results sheet: Sheet3.Range("A2:J1000").ClearContents This is done to clear out the results from any previous searches. Also, just before the freeze code, I have the following code: Sheet3.Columns.AutoFit Sheet3.Rows.AutoFit This is done to reduce the area of the results sheet as much as possible. Any ideas? Any help is greatly appreciated. -- JJFJR "T-ツョex" wrote: Hi! If you only want to freeze row 1, then you select cell A2. Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("A2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; Thanks for the response. I want to freeze the top row (header row) only...what do I select? I need all of the cells in the rest of the sheet to scroll. -- JJFJR "T-テつョex" wrote: Hi jjfjr! I tried the code you gave below and it didn't issue an error. But, it froze the wrong panes - the panes above and to the left of cell G18. If you want to freeze rows and/or columns, select the cell directly below the specified rows and to the right of the specified columns. Example, if you want to freeze row 1 and column A, you select, cell B2, which is directly below row 1 and to the right of column A. Then, FREEZE! Worksheets("Sheet3").Activate Worksheets("Sheet3").Range("B2").Select ActiveWindow.FreezePanes = True jjfjr Wrote: Hi; I have a workbook with three sheets - Search Form, Results and Data Table. The search form allows the user to type in information into one of ten fields. Each field is aasociated with a column in the data table ; any hits go into the results sheet. The header row of the data table goes in as the top row of the results sheet. I'd like to freeze the results top row so that when someone scrolls through, the top row stays on top so the user can see the column descriptions. Also. I'd like to have the header row of the results sheet print out no matter where the user has scrolled to. I saw the following code in another post but it gave me a "run-time error 9: subscript out of range" error; the second line was indicated as the culprit: Worksheets("Sheet3").Activate Sheet3.Range("A1:J1").Select ActiveWindow.FreezePanes = True Any help is greatly appreciated. -- JJFJR -- T-テつョex ------------------------------------------------------------------------ T-テつョex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=401601 -- T-ツョex ------------------------------------------------------------------------ T-ツョex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=401601 -- T-ョex ------------------------------------------------------------------------ T-ョex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=401601 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic: Get row count of a sheet in Excel | Excel Discussion (Misc queries) | |||
Visual Basic code not working when sheet is saved | Excel Discussion (Misc queries) | |||
Visual Basic - Variable Sheet Names | Excel Discussion (Misc queries) | |||
visual basic. find copy row past into new sheet | Excel Worksheet Functions | |||
changing the visual basic in office 2003 to visual studio net | Excel Discussion (Misc queries) |