Фокус ячейки в excel

Леонид1

1 / 1 / 0

Регистрация: 15.07.2011

Сообщений: 69

1

Передача фокуса определенной ячейке

26.10.2011, 10:24. Показов 12590. Ответов 8

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

Какой код написать в кнопке чтобы перемещаться в определенную ячейку определенного листа?
Вот так не работает:

Visual Basic
1
2
3
4
Private Sub CommandButton1_Click()
Sheets("Лист2").Select
    Range("C1").Select
End Sub



0



1562 / 1114 / 165

Регистрация: 23.07.2010

Сообщений: 6,454

26.10.2011, 10:29

2

Не верю (с)
Как именно «не работает»?



0



1 / 1 / 0

Регистрация: 15.07.2011

Сообщений: 69

26.10.2011, 10:30

 [ТС]

3

Runtime error 1004
метод select из класса Range завершен неверно



0



1562 / 1114 / 165

Регистрация: 23.07.2010

Сообщений: 6,454

26.10.2011, 10:33

4

Проверь Range(«C1») ,букву С — может русскую вписал. Ибо код 100% работоспособен



0



Казанский

15136 / 6410 / 1730

Регистрация: 24.09.2011

Сообщений: 9,999

26.10.2011, 10:33

5

Цитата
Сообщение от pincet
Посмотреть сообщение

Не верю (с)

А я верю

Visual Basic
1
2
3
4
Private Sub CommandButton1_Click()
Sheets("Лист2").Select
Sheets("Лист2").Range("C1").Select
End Sub

В модуле листа

свойства Range, Cells и т.д. без явного указания листа, относятся к Me, т.е. к этому листу, а не к ActiveSheet.



1



pincet

1562 / 1114 / 165

Регистрация: 23.07.2010

Сообщений: 6,454

26.10.2011, 10:34

6

Visual Basic
1
2
3
4
5
Sub Кнопка1_Щелчок()
Sheets(1).Select
Range("с1").Select
 
End Sub



1



Апострофф

Заблокирован

26.10.2011, 10:34

7

Или листа «Лист2» нет?



0



1562 / 1114 / 165

Регистрация: 23.07.2010

Сообщений: 6,454

26.10.2011, 10:39

8

Кстати, кнопка где лежит? На листе али на форме какой?
Если на форме, то Казанский из райт.



0



1 / 1 / 0

Регистрация: 15.07.2011

Сообщений: 69

26.10.2011, 10:41

 [ТС]

9

просто на листе, но Казанский вроде бы действительно прав, потому что с его изменениями код работает…
спасибо все заработало!



0



  • Remove From My Forums
  • Question

  • How do I set focus to a Cell. For Example I keep the cell G7 active and Close the Excel sheet. While I am opening it should set focus on D4. How is this possible

    I have tried the Following but none works.

    ActiveSheet.Cells(5, 4).Select
    				

    -or-

    ActiveSheet.Range("D5").Select
    

    • Edited by

      Tuesday, September 6, 2011 2:36 PM

Answers

  • How do I set focus to a Cell. For Example I keep the cell G7 active and Close the Excel sheet. While I am opening it should set focus on D4. How is this possible

    I have tried the Following but none works.

    ActiveSheet.Cells(5, 4).Select
    				

    -or-

    ActiveSheet.Range("D5").Select
    

      Ram, it depends where are you calling that code from :)

    Place the code in the workbook open event :)

    Option Explicit
    
    Private Sub Workbook_Open()
        ActiveSheet.Range("D5").Select '<~~ Change it to D4 if you want D4 to become Active
    End Sub
    

    See the image attached.

    Also ensure that the macros are enabled :)


    Sid (A good exercise for the Heart is to bend down and help another up) Please do not email me your questions. I do not answer questions by email unless I get paid for it :) If you want, create a thread in Excel forum and email me the link and I will help you
    if I can.

    • Edited by
      Siddharth Rout
      Wednesday, September 7, 2011 6:48 AM
    • Marked as answer by
      Calvin_Gao
      Wednesday, September 7, 2011 10:00 AM
    • Unmarked as answer by
      Calvin_Gao
      Wednesday, September 7, 2011 10:00 AM
    • Proposed as answer by
      Calvin_Gao
      Wednesday, September 7, 2011 10:00 AM
    • Marked as answer by
      Calvin_Gao
      Wednesday, September 14, 2011 5:50 AM

Перенос фокуса с курсора мыши на активную ячейку

Alex59

Дата: Вторник, 19.02.2019, 10:41 |
Сообщение № 1

Группа: Пользователи

Ранг: Прохожий

Сообщений: 2


Репутация:

0

±

Замечаний:
0% ±


Excel 2003

Здравствуйте.
Помогите решить проблему (не комфортность).
Описание:
1. Есть книга с 3-мя листами:

  • лист «Таблица» — заполняется переменной информацией. Имеет ключевые поля в колонке «А»
  • лист «Выборка» — при вводе номера ключевого поля в ячейку «А1», выполняется выборка инфы из листа «Таблица» и некая ее обработка
  • лист «Бланк» — бланк документа, заполняется обработанной инфой из листа «Выборка»

2. На листе «Таблица» имеется кнопка «Печать», при нажатии мышью на которую выполняются след. действия:

  • из строки, где находится активная ячейка выбирается ключевое поле
  • присваивается ячейке А1 листа «Выборка»
  • обрабатывается инфа на листе «Выборка»
  • заполняется лист «Бланк»
  • лист «Бланк» отправляется на печать
  • возвращается на лист «Таблица»

и вот тут проблема:

  • фокус мыши расположен на кнопке «Печать» (лист «Таблица»)
  • а фокус активной ячейки — где-то в недрах таблицы

Подскажите, пожалуйста, как вернуть фокус с мыши на ячейку

Процедура, привязянная к кнопке
[vba]

Код

Private Sub Out_for_Printer_Click()
    Dim i As Integer
    i = ActiveCell.Row    
    If i > 3 Then  ‘ не печатать шапку
        Application.ScreenUpdating = False
        Application.Volatile True
        Worksheets(«Выборка»).Cells(1, 1).Value = Worksheets(«Таблица»).Cells(i, 1).Value
        Worksheets(«Бланк»).PrintOut Copies:=1, Collate:=True
        Application.ScreenUpdating = True
    End If
    Sheets(«Таблица»).Select
End Sub

[/vba]

Заранее спасибо

Сообщение отредактировал Alex59Вторник, 19.02.2019, 12:07

 

Ответить

vikttur

Дата: Вторник, 19.02.2019, 12:14 |
Сообщение № 2

Группа: Друзья

Ранг: Участник клуба

Сообщений: 2941

[vba]

Код

     Dim r As Range

     Set r = ActiveCell
………….
     r.Select
     Set r =Nothing
End Sub

[/vba]

Сообщение отредактировал viktturВторник, 19.02.2019, 12:15

 

Ответить

Alex59

Дата: Понедельник, 01.04.2019, 10:34 |
Сообщение № 3

Группа: Пользователи

Ранг: Прохожий

Сообщений: 2


Репутация:

0

±

Замечаний:
0% ±


Excel 2003

Уважаемый vikttur, спасибо за помощь

 

Ответить

01.01.2007

Когда мы уже умеем открывать книгу, выбирать рабочий лист и сохранять книгу, то чтобы создать простой документ в Excel, необходимо и достаточно научиться записывать информацию в ячейки таблицы. Шаблоны многих документов уже разработаны и представлены в разнообразных справочных системах, и целесообразно научиться использовать их в своих приложениях.

Лист книги Excel состоит из множества строк и столбцов, пересечения которых представляют собой отдельные ячейки или множество ячеек, если пересекается множество строк и столбцов. Каждая ячейка может содержать информацию в виде данных различного типа или формул. Кроме данных, ячейка имеет другие свойства, которые определяют ее размер, цвет, стиль, формат данных и другие параметры.

Доступ к ячейке или ячейкам в Excel предоставляет объект Range. Этот объект обладает всеми необходимыми свойствами и методами, чтобы писать, читать из ячейки и изменять все ее свойства. Для того, чтобы просто записать информацию в ячейку, необходимо присвоить объекту Range значение, записанное в переменной типа variant. Например: Range[‘A1’]:=123.25; или Range[‘A1′]:=’ячейка’;. Для записи (чтения) в ячейку из приложений на Delphi разработаем несколько функций. Аргумент (range:string) этих функций может принимать значения, которые соответствуют одной ячейке (например ‘A1’) или группе ячеек (например ‘A1:D5’).

Identify what active cells and sheets are in your spreadsheet

Updated on January 4, 2020

In spreadsheet programs such as Excel or Google Spreadsheets, the active cell is identified by a colored border or outline surrounding the cell. The active cell is always in the active sheet.

Cells and Sheets

The active cell is also known as the current cell or the cell that holds the focus of the cursor. Even if you’ve selected several cells, only one normally has focus, which, by default, is selected to receive input. For example, data entered with the keyboard or pasted from a clipboard is sent to the cell which has focus. An exception is when an array formula is entered into multiple cells at the same time.

Similarly, the active sheet or current sheet is the worksheet containing the active cell. Like the active cell, the active sheet is considered to have focus when it comes to performing actions that affect one or more cells — such as formatting — and the changes occur to the active sheet by default.

The active cell and sheet can easily be changed. In the case of the active cell, either clicking another cell with the mouse pointer or pressing the arrow keys on the keyboard will both result in a new active cell being selected.

Change the active sheet by clicking a different sheet tab with the mouse pointer or by using a keyboard shortcut.

Active Cell and the Name Box

The cell reference for the active cell appears in the Name Box, located above Column A in a worksheet. If the active cell has been given a name, either on its own or as part of a range of cells, the range name is displayed in the Name Box instead.

Changing the Active Cell within a Group of Highlighted Cells

If a group or range of cells have been selected the active cell can be changed without re-selecting the range using the following keys on the keyboard:

  • Enter: moves the active cell highlight down one cell within the selected range.
  • Shift+Enter: moves the active cell highlight up one cell within the selected range.
  • Tab: moves the active cell one cell to the right within the selected range.
  • Shift+Enter: moves the active cell one cell to the left within the selected range.
  • Ctrl + . (period): moves the active cell clockwise to the next corner of the selected range.

Moving the Active Cell to Different Group of Selected Cells

If more than one group or range of non-adjacent cells is highlighted in the same worksheet, the active cell highlight can be moved between these groups of selected cells using the following keys on the keyboard:

  • Ctrl+Alt+Right Arrow: moves the active cell highlight to the next non-adjacent range to the right of the current location.
  • Ctrl+Alt+Left Arrow: moves the active cell highlight to the next non-adjacent range to the left of the current location.

Selecting Multiple Sheets and the Active Sheet

Even though it is possible to select or highlight more than one worksheet at one time, only the active sheet name is in bold and most changes made when multiple sheets are selected will still only affect the active sheet.

Changing the Active Sheet With Shortcut Keys

Change the active sheet by clicking the tab of another sheet with the mouse pointer, or use shortcut keys:

In Excel

  • Moving to the sheet to the left: Ctrl+PgUp.
  • Moving to the sheet to the right: Ctrl+PgDn.

In Google Spreadsheets

  • Moving to the sheet to the left: Ctrl+Shift+PgUp.
  • Moving to the sheet to the right: Ctrl+Shift+PgDn.

Thanks for letting us know!

Get the Latest Tech News Delivered Every Day

Subscribe

Понравилась статья? Поделить с друзьями:
  • Финансовый тип данных excel
  • Фирменный бланк компании шаблон word
  • Фокус в vba для excel
  • Финансовый результат формула excel
  • Фирменный бланк примеры word