Loncat ke daftar isi utama

Bagaimana cara meletakkan nilai sel di header / footer di Excel?

Kita dapat dengan mudah memasukkan header atau footer yang berisi path file, nama file, tanggal sekarang atau informasi lain dengan fitur Excel, tetapi terkadang kita ingin menggunakan nilai sel sebagai header atau footer di Excel. Bagaimana kita bisa meletakkan konten sel ke header atau footer di buku kerja?

Letakkan nilai sel di header atau footer lembar kerja dengan kode VBA

Letakkan nilai sel di header atau footer dari semua lembar kerja dengan kode VBA

Masukkan informasi file ke header / footer dengan Kutools for Excel ide bagus3


Jika Anda ingin menempatkan konten sel di header atau footer lembar kerja saat ini, kode VBA berikut dapat membantu Anda. Silakan lakukan langkah-langkah berikut:

1. Aktifkan lembar kerja Anda yang ingin Anda sisipkan herder atau footer dengan nilai sel, lalu tahan ALT + F11 kunci, dan itu membuka Jendela Microsoft Visual Basic for Applications.

2.Klik Menyisipkan > Modul, dan tempel kode berikut di Module Window.

Kode VBA: letakkan nilai sel tertentu di header lembar kerja

Sub HeaderFrom()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
Application.ActiveSheet.PageSetup.LeftHeader = WorkRng.Range("A1").Value
End Sub

3. Lalu tekan F5 kunci untuk menjalankan kode ini, sebuah dialog akan muncul untuk mengingatkan Anda memilih sel yang ingin Anda masukkan isinya ke dalam header.doc-masukkan-nilai-sel-ke-header1

4. Dan kemudian klik OK, nilai sel yang ditentukan ini telah dimasukkan ke dalam tajuk kiri lembar kerja saat ini. Anda dapat melihat header dengan mengklik File > Mencetak. Lihat tangkapan layar:doc-masukkan-nilai-sel-ke-header1

Catatan:

1. Jika Anda ingin menggunakan konten sel sebagai footer lembar kerja aktif, Anda dapat menerapkan kode ini:

Kode VBA: letakkan nilai sel tertentu di footer lembar kerja

Sub FooterFrom()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
Application.ActiveSheet.PageSetup.LeftFooter = WorkRng.Range("A1").Value
End Sub

2. Anda juga dapat menerapkan kode di atas untuk memasukkan nilai sel ke header / footer kanan atau header / footer tengah, cukup ganti KiriHeader / Kaki Kiri dengan KananHeader / Kaki Kanan or Kepala Pusat / Pusat Footer dalam kode.


Terkadang, Anda ingin menyisipkan header atau footer dengan konten sel yang dipilih ke semua lembar kerja dari buku kerja pembuka Anda, dengan kode di atas, Anda perlu mengulanginya berkali-kali. Dalam kasus ini, kode VBA berikut bisa menambahkan konten sel ke penggembala atau footer dari seluruh buku kerja sekaligus.

1. Aktifkan buku kerja Anda yang ingin Anda sisipkan herder atau footer dengan nilai sel, lalu tahan ALT + F11 kunci, dan itu membuka Jendela Microsoft Visual Basic for Applications.

2. Klik Menyisipkan > Modul, dan tempel kode berikut di Jendela Modul.

Kode VBA: letakkan nilai sel tertentu di footer dari semua lembar kerja

Sub AddFooterToAll()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
For Each ws In Application.ActiveWorkbook.Worksheets
    ws.PageSetup.LeftFooter = WorkRng.Range("A1").Value
Next
End Sub

3. Lalu tekan F5 kunci untuk mengeksekusi kode ini, sebuah dialog akan muncul untuk mengingatkan Anda memilih sel yang ingin Anda letakkan isinya di footer seluruh workbook.

doc-masukkan-nilai-sel-ke-header1

4. Dan kemudian klik OK, nilai sel yang dipilih ini telah ditambahkan ke semua footer kiri lembar kerja. Anda dapat melihat footer dengan mengklik File > Mencetak. Lihat tangkapan layar:

doc-masukkan-nilai-sel-ke-header1

Catatan:

1. Jika Anda ingin menggunakan konten sel sebagai header dari seluruh workbook, Anda dapat menerapkan kode ini:

Kode VBA: letakkan nilai sel tertentu di header semua lembar kerja

Sub AddHeaderToAll()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
For Each ws In Application.ActiveWorkbook.Worksheets
    ws.PageSetup.LeftHeader = WorkRng.Range("A1").Value
Next
End Sub

2. Pengganti RightHeader / Footer or CenterHeader / Footer untuk LeftHeader / Footer dalam kode di atas jika Anda ingin header atau footer Anda ditempatkan secara berbeda.


Jika Anda ingin memasukkan informasi filer ke header atau footer, seperti nama lembar kerja / buku kerja, jalur buku kerja dan sebagainya, Anda bisa menggunakan Kutools untuk Excel'S Masukkan Informasi Buku Kerja Utilitas jika Anda telah menginstal Kutools for Excel.

Kutools untuk Excel, dengan lebih dari 300 fungsi praktis, membuat pekerjaan Anda lebih mudah. 

Setelah pemasangan gratis Kutools for Excel, lakukan seperti di bawah ini:

1. klik Kutools Ditambah > Buku catatan > Masukkan Informasi Buku Kerja. Lihat tangkapan layar:
dok kte 1

2. Dalam Masukkan Informasi Buku Kerja dialog, periksa informasi yang perlu Anda masukkan di bawah Informasi bagian, dan periksa Header or Footer sesukamu.

olymp trade indonesiaTip: Anda dapat memasukkan informasi di tiga lokasi header atau footer: tengah, kiri atau kanan.
doc memasukkan jalur buku kerja 1

3. klik Ok. Lalu Anda bisa pergi ke View > Page Layout untuk melihat tajuk.
dok kte 3

Dengan Sisipkan Informasi Buku Kerja, Anda juga bisa menyisipkan informasi file ke sel atau rentang sel. Klik di sini untuk mengetahui lebih banyak tentang utilitas ini.



Ketik.Jika Anda ingin dengan cepat membagi buku kerja menjadi beberapa buku kerja / file pdf atau file csv secara terpisah, silakan coba gunakan Kutools for Excel's Pisahkan Buku Kerja seperti yang ditunjukkan pada tangkapan layar berikut. Ini berfungsi penuh tanpa batasan dalam 30 hari, silakan unduh dan dapatkan uji coba gratis sekarang.

doc split buku kerja

Artikel terkait:

Bagaimana cara memasukkan nama file atau jalur ke sel / header atau footer di Excel?

Bagaimana cara menyisipkan dan menghapus gambar header, footer, dan header di Excel?

Alat Produktivitas Kantor Terbaik

馃 Kutools AI Ajudan: Merevolusi analisis data berdasarkan: Eksekusi Cerdas   |  Hasilkan Kode  |  Buat Rumus Khusus  |  Analisis Data dan Hasilkan Grafik  |  Aktifkan Fungsi Kutools...
Fitur Populer: Temukan, Sorot, atau Identifikasi Duplikat   |  Hapus Baris Kosong   |  Gabungkan Kolom atau Sel tanpa Kehilangan Data   |   Putaran tanpa Formula ...
Pencarian Super: VLookup Beberapa Kriteria    VLookup Nilai Berganda  |   VLookup di Beberapa Lembar   |   Pencarian Fuzzy ....
Daftar Drop-down Lanjutan: Buat Daftar Drop Down dengan Cepat   |  Daftar Drop Down yang Bergantung   |  Multi-pilih Drop Down List ....
Manajer Kolom: Tambahkan Jumlah Kolom Tertentu  |  Pindahkan Kolom  |  Alihkan Status Visibilitas Kolom Tersembunyi  |  Bandingkan Rentang & Kolom ...
Fitur Unggulan: Fokus Kisi   |  Tampilan Desain   |   Bar Formula Besar    Manajer Buku Kerja & Lembar   |  Perpustakaan Sumberdaya (Teks otomatis)   |  Pemetik tanggal   |  Gabungkan Lembar Kerja   |  Enkripsi/Dekripsi Sel    Kirim Email berdasarkan Daftar   |  Filter Super   |   Filter Khusus (filter tebal/miring/coret...) ...
15 Perangkat Teratas12 Teks Tools (Tambahkan Teks, Hapus Karakter, ...)   |   50 + Grafik jenis (Gantt Chart, ...)   |   40+ Praktis Rumus (Hitung usia berdasarkan ulang tahun, ...)   |   19 Insersi Tools (Masukkan Kode QR, Sisipkan Gambar dari Jalur, ...)   |   12 Konversi Tools (Angka ke Kata, Konversi Mata Uang, ...)   |   7 Gabungkan & Pisahkan Tools (Lanjutan Gabungkan Baris, Pisahkan Sel, ...)   |   ... dan banyak lagi

Tingkatkan Keterampilan Excel Anda dengan Kutools for Excel, dan Rasakan Efisiensi yang Belum Pernah Ada Sebelumnya. Kutools for Excel Menawarkan Lebih dari 300 Fitur Lanjutan untuk Meningkatkan Produktivitas dan Menghemat Waktu.  Klik Di Sini untuk Mendapatkan Fitur yang Paling Anda Butuhkan...

Deskripsi Produk


Tab Office Membawa antarmuka Tab ke Office, dan Membuat Pekerjaan Anda Jauh Lebih Mudah

  • Aktifkan pengeditan dan pembacaan tab di Word, Excel, PowerPoint, Publisher, Access, Visio, dan Project.
  • Buka dan buat banyak dokumen di tab baru di jendela yang sama, bukan di jendela baru.
  • Meningkatkan produktivitas Anda sebesar 50%, dan mengurangi ratusan klik mouse untuk Anda setiap hari!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This doesn't appear to make a dynamic link, i.e., the value entered into the header doesn't change when the value of the cell does. So what is the purpose of the VBA code, when a copy/paste will do the same?
This comment was minimized by the moderator on the site
Hello, Neil,
If you want to link the cell value to the header or footer dynamically, please apply the following VBA code:

Note: You should insert the code into the sheet code not the normal Module.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim WorkRng As Range
Dim xStR As String
On Error Resume Next
xStR = "A1" '
Set WorkRng = Intersect(Application.ActiveSheet.Range("A1"), Target)
If WorkRng Is Nothing Then Exit Sub
Application.ActiveSheet.PageSetup.RightHeader = WorkRng.Range("A1").Value
End Sub


Please have a try, hope it can help you
This comment was minimized by the moderator on the site
maksudnya bagaimana?
This comment was minimized by the moderator on the site
Hi,

This appears to only work once.
What if the value of the cell changes?
Is there a way to link the cell so the header changes when the cell value changes?

I have a workbook where I have three sheets.

Sheet 1 labeled "Deletion Sheet" - Sheet we send to the warehouse with info what to palatalize for the order
Sheet 2 labeled "OA" - My order acknowledgement to the customer which pulls most of the data from the first sheet including the Order number which I need to have in my header. So I am trying to link the Header to the cell in this page with the order number (F5) which gets it's value from (C7) in the first work sheet ("Deletion Sheet")
Sheet 3 labeled "Invoice - Invoice which also pulls most of the same information from the first sheet which would also need the header to include the value (F5) of this sheet taken from (C7) in "Deletion Sheet"
This comment was minimized by the moderator on the site
When using your "VBA code: put a specified cell value in header of all worksheets", I would like the value placed to be formatted: Tahoma, bold, in font size 12.
How can this be added to your code?
This comment was minimized by the moderator on the site
Hi There, Is there a way that you can add a cell value which takes account of applied filters? For example... A1 = Monday A2 = Tuesday A3 = Wednesday. Using the VBA code to display cell A1 will work initially, but once I apply a filter on days of the week, the "top" cell value is no longer A1. Is there a way to pick up the variable? Many thanks,
This comment was minimized by the moderator on the site
I want to insert four cells in header.This VB is only for one cell. How can I do it. Thanks
This comment was minimized by the moderator on the site
You can try Concatenating the value of rht four cells into a single cell and then use the single cell as the header.
This comment was minimized by the moderator on the site
I needed to insert an active payroll date range into multiple sheets. The user opens the Payroll Date sheet, enters the date range and before she prints it updates all the sheets in the workbook. Here is how I am able to insert multiple cells into the range with a bit less code 2010 compatible: Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim WorkRng As Range On Error Resume Next For Each ws In Application.ActiveWorkbook.Worksheets ws.PageSetup.RightHeader = Range("'Payroll Date'!A1").Value & vbCr & Range("'Payroll Date'!A2").Value Next End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations