Skip i'r prif gynnwys

Sut i gadw siart mewn golwg bob amser wrth sgrolio yn Excel?

Os oes siart wedi'i mewnosod mewn dalen, wrth i chi sgrolio'r ddalen i lawr i weld y data, ni ellir edrych ar y siart ar yr un pryd ag islaw'r screenshot a ddangosir, y mae'n rhaid iddo fod yn gas. Yn yr erthygl hon, rwy'n cyflwyno cod VBA i gadw siart bob amser yn y golwg er wrth sgrolio'r ddalen i lawr neu i fyny.

doc cadw siart yng ngolwg 1
saeth doc i lawr
doc cadw siart yng ngolwg 2

Cadwch siart mewn golwg bob amser


swigen dde glas saeth Cadwch siart mewn golwg bob amser

Er mwyn cadw siart mewn golwg wrth sgrolio taflen, gallwch wneud cais o dan god VBA i'w datrys.

1. Cliciwch ar y dde ar y tab dalen rydych chi am gadw'r siart yn weladwy, a chlicio Gweld y Cod ffurfio'r ddewislen cyd-destun. Gweler y screenshot:
doc cadw siart yng ngolwg 3

2. Yn y popping Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, pastiwch y cod islaw'r sgript wag.

VBA: Cadwch y siart bob amser yn y golwg

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyExtendoffice20161111
    Dim CPos As Double
    Application.ScreenUpdating = False
    CPos = ActiveWindow.ScrollRow * ActiveCell.RowHeight
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveSheet.Shapes("Chart 2").Top = CPos
    ActiveWindow.Visible = False
    Application.ScreenUpdating = True
End Sub

doc cadw siart yng ngolwg 5

3. Cadw a chau'r ymgom, yna bydd y siart yn cael ei symud i lawr neu i fyny wrth i chi glicio ar unrhyw gell.
doc cadw siart yng ngolwg 6

Nodiadau:

(1) Yn y cod VBA, Siart 2 yw'r enw siart rydych chi am ei gadw mewn golwg, gallwch ei newid yn ôl yr angen.

(2) Ni all y VBA hwn gadw grŵp o siartiau mewn golwg bob amser.

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (15)
Rated 4.75 out of 5 · 2 ratings
This comment was minimized by the moderator on the site
A mí me pasa que la siguiente vez que abro el archivo, el script ya no funciona. Tengo que copiarlo, borrarlo, cerrar el archivo tras guardarlo, volver a abrir el archivo y volver a pegar el script en VBA. ¿Alguna solución?
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Hi, save the workbook as excel macro enable workbook, the vba will be work when open next time.https://cdn.extendoffice.com/images/stories/comments/sun-comment/doc-macro-enable.png
This comment was minimized by the moderator on the site
I encountered a problem with unselecting the cell and needed two charts, So I made some changes and it seems to work now.
To use it put the right Chart Name.
*Note: This one is for two charts


Private Sub worksheet_selectionchange(ByVal target As Range)
Dim chartposition As Double

chartposition = ActiveWindow.ScrollRow * ActiveCell.RowHeight
ActiveSheet.Shapes("Chart 2").Top = chartposition

ActiveSheet.ChartObjects("Chart 3").Top = chartposition + 250

End Sub
This comment was minimized by the moderator on the site
Can any one assist. when i follow theses steps


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyExtendoffice20161111
Dim CPos As Double
Application.ScreenUpdating = False
CPos = ActiveWindow.ScrollRow * ActiveCell.RowHeight
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveSheet.Shapes("Chart 2").Top = CPos
ActiveWindow.Visible = False
Application.ScreenUpdating = True
End Sub


i get the following err

Run-Time error '-2147024809 (80070057)':
The item with the specified name was not found

when i debug
ActiveSheet.ChartObjects("Chart 2").Activate
This comment was minimized by the moderator on the site
Hi, Christo, you need to change the chart name "Chart 2" to your chart really name in the script. You can click at the chart and see its name in the name box. See screenshot:
https://www.extendoffice.com/images/stories/comments/sun-comment/do_chart_name.png
This comment was minimized by the moderator on the site
yes thanks. after a made the question i realised my chart name was wrong
thanks

ps.
do you perhaps know how i can make the chart kept in view as i scroll without clicking where it must follow
This comment was minimized by the moderator on the site
can I use Kutools to automatically use that VBA for my charts??
This comment was minimized by the moderator on the site
Sorry, Wangnuli, Kutools has not support this so far.
This comment was minimized by the moderator on the site
Hola muchas gracias por el código, utilizando este código ¿Hay alguna manera de limitar qué tan alto en la hoja se reubicará el gráfico? por ejemplo, no quiero que se coloque encima de la fila 9. Ayuda por favor.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Is there a way to limit how high up on the sheet the chart will relocate to? I don't want it to affix above row 8
This comment was minimized by the moderator on the site
Is there a similar formula that can be built for Google Sheets?
This comment was minimized by the moderator on the site
This macro did exactly what I wanted. However it created another problem that I wondered if you might have a solution to.

While this macro is active I cannot select cells for other purposes such as formatting or merging them. Click and drag, shift nor ctrl work to select a group of cells. I can only select the one cell I clicked on. I frequently want to change formatting (background, fill down a formula, etc.) The only way I have been able to do this is to delete the macro, save, make my formatting changes, paste the macro back in and save.

Is there a simpler way to do this? Perhaps:

1. (preferred) A simple keystroke that would temporarily disable the macro and then re-enable it.

2. Some code added to the macro to allow selection of a group of cells.

Dennis
This comment was minimized by the moderator on the site
This was good but I wish there was a way that it would just move with the scroll wheel, like heading lines. Also if I want to select a cell it takes two clicks. The first click moves the chart but also selects the chart so I have to click again to select the cell.
This comment was minimized by the moderator on the site
I added "activecell.select" on the last line of this code and it fixed the double clicking issue. It will automatically select the last active cell, which will be the one you clicked on to move the chart. Hope this helps.
This comment was minimized by the moderator on the site
THIS IS WHAT I NEEDED! GOLDEN!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations