ไปยังเนื้อหาหลัก

วิธีใช้ / อ้างอิงค่าจากแผ่นงานก่อนหน้าใน Excel

วิธีอ้างอิงค่าเซลล์เฉพาะจากแผ่นงานก่อนหน้าเมื่อสร้างสำเนาใน Excel ตัวอย่างเช่นเมื่อสร้างสำเนาของ Sheet2 คุณอาจต้องการอ้างอิงเซลล์ A1 ของ Sheet2 โดยอัตโนมัติในแผ่นงานที่คัดลอกใหม่ (กล่าวว่า Sheet3) จะบรรลุได้อย่างไร? บทความนี้จะช่วยคุณ

ใช้ / อ้างอิงค่าจากแผ่นงานก่อนหน้าด้วยฟังก์ชันที่ผู้ใช้กำหนดเอง
ใช้ / อ้างอิงค่าจากแผ่นงานก่อนหน้าด้วย Kutools for Excel


ใช้ / อ้างอิงค่าจากแผ่นงานก่อนหน้าด้วยฟังก์ชันที่ผู้ใช้กำหนดเอง

ตามความจริงแล้วไม่มีวิธีใดสามารถอ้างอิงค่าเซลล์บางอย่างโดยอัตโนมัติเมื่อสร้างสำเนาของแผ่นงาน จริงๆแล้วคุณสามารถสร้างแผ่นงานใหม่จากนั้นอ้างอิงค่าเซลล์จากแผ่นงานก่อนหน้าด้วยฟังก์ชันที่ผู้ใช้กำหนดต่อไปนี้

1. หลังจากสร้างเวิร์กชีตเปล่าใหม่แล้ว (ระบุว่า Sheet3) โปรดกด อื่น ๆ + F11 ในเวลาเดียวกันเพื่อเปิดไฟล์ Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

2 ใน Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่างคลิก สิ่งที่ใส่เข้าไป > โมดูล. จากนั้นคัดลอกและวางรหัส VBA ต่อไปนี้ลงในหน้าต่างรหัส

VBA: ใช้ / อ้างอิงค่าจากแผ่นงานก่อนหน้าใน Excel

Function PrevSheet(RCell As Range)
    Dim xIndex As Long
    Application.Volatile
    xIndex = RCell.Worksheet.Index
    If xIndex > 1 Then _
        PrevSheet = Worksheets(xIndex - 1).Range(RCell.Address)
End Function

3 กด อื่น ๆ + Q พร้อมกันเพื่อปิดไฟล์ Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

4. เลือกเซลล์ว่างของ Sheet3 (พูดว่า A1) ป้อนสูตร = PrevSheet (A1) เข้าไปใน สูตรบาร์ จากนั้นกดปุ่ม เข้าสู่ กุญแจ

ตอนนี้คุณจะได้รับค่าเซลล์ A1 ของแผ่นงานก่อนหน้า (Sheet2) ในแผ่นงานปัจจุบัน

หมายเหตุ: รหัสจะระบุแผ่นงานซึ่งเป็นของแผ่นงานก่อนหน้านี้โดยอัตโนมัติ


ใช้ / อ้างอิงค่าจากแผ่นงานก่อนหน้าด้วย Kutools for Excel

กับ อ้างถึงเวิร์กชีตแบบไดนามิก ประโยชน์ของ Kutools สำหรับ Excelคุณสามารถใช้หรืออ้างอิงค่าจากแผ่นงานก่อนหน้าใน Excel ได้อย่างง่ายดาย

ก่อนที่จะใช้ Kutools สำหรับ Excelโปรด ดาวน์โหลดและติดตั้งในตอนแรก.

1. หากคุณต้องการอ้างอิงค่าของเซลล์ A1 จากแผ่นงานก่อนหน้าไปยังแผ่นงานปัจจุบันโปรดเลือกเซลล์ A1 ในแผ่นงานปัจจุบันแล้วคลิก Kutools > More > อ้างถึงเวิร์กชีตแบบไดนามิก. ดูภาพหน้าจอ:

2 ใน กรอกข้อมูลอ้างอิงในแผ่นงาน ให้ตรวจสอบเฉพาะชื่อแผ่นงานก่อนหน้าในไฟล์ รายการแผ่นงาน จากนั้นคลิกที่ไฟล์ เติมช่วง ปุ่ม

จากนั้นคุณจะเห็นค่าของเซลล์ A1 ในแผ่นงานก่อนหน้านี้อ้างอิงในแผ่นงานปัจจุบัน

หมายเหตุ: ด้วยยูทิลิตี้นี้คุณสามารถอ้างอิงค่าเซลล์เดียวกันจากแผ่นงานต่างๆลงในแผ่นงานปัจจุบันพร้อมกันได้

  หากคุณต้องการทดลองใช้ยูทิลิตีนี้ฟรี (30 วัน) กรุณาคลิกเพื่อดาวน์โหลดแล้วไปใช้การดำเนินการตามขั้นตอนข้างต้น


ใช้ / อ้างอิงค่าจากแผ่นงานก่อนหน้าด้วย Kutools for Excel

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
Comments (22)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, Your code works perfectly! The intent for me is to fill a column on one of the worksheets which would update a linear graph. My question is, how do I add the new number entered on a new worksheet, while still maintaining the numbers the same of the previous sheets. For example, I entered PrevSheet(A1) on Sheet 2, which takes the number for A1 cell from Sheet 1. So I went to cell A2 of Sheet 2, and entered PrevSheet(A1) again. The intent is if I copy and paste a new sheet (Let's call it Sheet N), and I update cell A1 in Sheet N with a different value, Sheet 2 will have the value from Sheet 1 in cell A1, and the Value from Sheet N in cell A1 in cell A2. But what happens is that is updates both cell A1 and A2 in Sheet 2 to the same values as in Sheet N. This makes sense because it's taking the values from the previous sheet. Hope I didn't confuse you. Thanks!
This comment was minimized by the moderator on the site
Hey.

I'm using Greek Office 365 with all updates installed, and I can't get this to work.

It returns name error at the cell I input =PrevSheet(A1).

Both sheets have the vba code and the file is saved as .xlsb

Any clues?
Thanks in advance :)
This comment was minimized by the moderator on the site
Hi Sotos,
You need to put the VBA in the Module (code) window (press the Alt + F11 keys to open the Visual Editor, click Insert > Module to add a new Module editor, and the enter the code). Then apply the formula.
This comment was minimized by the moderator on the site
THANK YOU VERY VERY MUCH! VERY HELPFUL!
This comment was minimized by the moderator on the site
Excellent!!! VBA code thanks a lot
This comment was minimized by the moderator on the site
Excellent I have used previous sheet function, but, if i do any additions of rows or columns in previous sheet, the values are getting change I want constant result. for example if i select =prevsheet(A6) where the value is there, but in the previous sheet if I add one row the value will go to A7, but in current sheet it is taking the value of A6 only, can u help me
This comment was minimized by the moderator on the site
I tried the code but it returns formulas not allowed. The cell of the previous worksheet is a result of a formula., how do you bypass the formula and return the result? The previous sheet cell returns the formula of =SUM(L38:L39)-L40
This comment was minimized by the moderator on the site
Hi RudyT,I tested it in the circumstance you mentioned, but I have no problem here. Which Excel version are you using?
This comment was minimized by the moderator on the site
Wow, that was 3 months ago, but surely appreciate the reply...

I don't know how to check Excel 365... The problem is I have a a value that I want to pass to new sheet, that must read, get value of previous sheet without naming it. Just get the previous sheet value. Your code passes the code of the previous sheet, and not the value. Because the value of the cell is a formula that gathers the totals from 2 other cells.
This comment was minimized by the moderator on the site
I followed steps 1-4, but I keep getting a #NAME error. Excel 2016. Please advise?
This comment was minimized by the moderator on the site
Hi Anon,
The code works well in my Excel 2016. Did you find specific error reminded in your code window when getting the #NAME error result?
This comment was minimized by the moderator on the site
I followed steps 1-4 but I keep returning a #NAME? error - Please advise?
This comment was minimized by the moderator on the site
Hi Andrew,
Which Office version do you use?
This comment was minimized by the moderator on the site
What about use value from Next Sheet?
This comment was minimized by the moderator on the site
Hi Alex,
To get the value from next Sheet, please replace the minus sign with plus sign in the sixh line of the code:
PrevSheet = Worksheets(xIndex + 1).Range(RCell.Address)
This comment was minimized by the moderator on the site
Hi Crystal, I tried replacing the minus sign with a plus sign but it didn't work - the relevant cell just returned a zero. I'm just wanting the change(s) required to do exactly as above BUT with the workbook numbering going from right to left, ie. Sheet3, Sheet 2, Sheet1 (the previous sheet will be the one to the right). Thanks
This comment was minimized by the moderator on the site
Hi Mav,
The method works based on the worksheets' order in your workbook. ie. The worksheets order from left to right are Sheet3, Sheet2 and Sheet1. For Sheet2, it's previous worksheet is Sheet3, and it's next worksheet is Sheet1.
This comment was minimized by the moderator on the site
Hi Crystal,
Yes I know. My query (like Alex's) is what change is required to make it work the other way, ie, for the next sheet, where the next sheet is to the left of the preceding sheet? You wrote to Alex,
"please replace the minus sign with plus sign in the sixh line of the code:
PrevSheet = Worksheets(xIndex + 1).Range(RCell.Address)".
My comment was just to say that that particular change did not work and to ask if you have a way that will actually work.
This comment was minimized by the moderator on the site
I've been looking for something to do this forever, thank you so much you have no idea. I have a simple spreadsheet for data entry weekly and a new tab for each week. the days, date, week #, etc goes +1 and then it grabs from previous sheet and moves to new one, this created a fast solution to data transfering to different sheets--- Again thank you
This comment was minimized by the moderator on the site
Good Day,
Sorry I can’t help with this, you can post your question in our forum: https://www.extendoffice.com/forum.html to get more Excel supports from our professional.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations