Bỏ qua nội dung chính

Làm thế nào để sử dụng / tham chiếu giá trị từ trang tính trước đó trong Excel?

Làm cách nào để tham chiếu một giá trị ô cụ thể từ trang tính trước đó khi tạo bản sao trong Excel? Ví dụ: khi tạo một bản sao của Trang tính2, bạn có thể muốn tự động tham chiếu ô A1 của Trang tính2 vào trang tính được sao chép mới (cho biết Trang tính 3). Làm thế nào để đạt được nó? Bài viết này sẽ giúp bạn.

Sử dụng / giá trị tham chiếu từ trang tính trước với chức năng Do người dùng xác định
Sử dụng / giá trị tham chiếu từ trang tính trước với Kutools cho Excel


Sử dụng / giá trị tham chiếu từ trang tính trước với chức năng Do người dùng xác định

Thành thật mà nói, không có phương pháp nào có thể tự động tham chiếu giá trị ô nhất định khi tạo bản sao của trang tính. Trên thực tế, bạn có thể tạo một trang tính mới và sau đó tham chiếu giá trị ô từ trang tính trước bằng hàm do người dùng xác định sau.

1. Sau khi tạo một trang tính trống mới (cho biết Sheet3), vui lòng nhấn Khác + F11 chìa khóa cùng một lúc để mở Microsoft Visual Basic cho các ứng dụng cửa sổ.

2. bên trong Microsoft Visual Basic cho các ứng dụng cửa sổ, nhấp Chèn > Mô-đun. Sau đó sao chép và dán mã VBA sau vào cửa sổ Mã.

VBA: Sử dụng / giá trị tham chiếu từ trang tính trước đó trong 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. Nhấn nút Khác + Q các phím đồng thời để đóng Microsoft Visual Basic cho các ứng dụng cửa sổ.

4. Chọn một ô trống của Sheet3 (cho biết A1), nhập công thức = PrevSheet (A1) vào Thanh công thức và sau đó nhấn nút đăng ký hạng mục thi Chìa khóa.

Bây giờ bạn sẽ nhận được giá trị ô A1 của trang tính trước đó (Sheet2) trong trang tính hiện tại.

Chú thích: Mã sẽ tự động xác định trang tính thuộc về trang tính trước đó của trang tính hiện tại.


Sử dụng / giá trị tham chiếu từ trang tính trước với Kutools cho Excel

Với Tham khảo động đến Trang tính tiện ích của Kutools cho Excel, bạn có thể dễ dàng sử dụng hoặc tham chiếu giá trị từ trang tính trước đó trong Excel.

Trước khi áp dụng Kutools cho Excel, Xin vui lòng tải xuống và cài đặt nó trước tiên.

1. Nếu bạn muốn tham chiếu giá trị của ô A1 từ trang tính trước sang trang tính hiện tại, vui lòng chọn ô A1 trong trang tính hiện tại và sau đó nhấp vào Kutools > Hơn > Tham khảo động đến Trang tính. Xem ảnh chụp màn hình:

2. bên trong Điền vào Tham chiếu Trang tính hộp thoại, chỉ kiểm tra tên trang tính trước đó trong Danh sách bảng tính và sau đó bấm vào Điền Phạm vi .

Sau đó, bạn có thể thấy giá trị của ô A1 trong trang tính trước đó được tham chiếu trong trang tính hiện tại.

Chú thích: Với tiện ích này, bạn có thể tham chiếu cùng một giá trị ô từ các trang tính khác nhau vào trang tính hiện tại cùng một lúc.

  Nếu bạn muốn dùng thử miễn phí (30 ngày) tiện ích này, vui lòng nhấp để tải xuống, và sau đó đi đến áp dụng hoạt động theo các bước trên.


Sử dụng / giá trị tham chiếu từ trang tính trước với Kutools cho Excel

Công cụ năng suất văn phòng tốt nhất

🤖 Trợ lý AI của Kutools: Cách mạng hóa việc phân tích dữ liệu dựa trên: Thực thi thông minh   |  Tạo mã  |  Tạo công thức tùy chỉnh  |  Phân tích dữ liệu và tạo biểu đồ  |  Gọi các hàm Kutools...
Các tính năng phổ biến: Tìm, đánh dấu hoặc xác định các bản sao   |  Xóa hàng trống   |  Kết hợp các cột hoặc ô mà không làm mất dữ liệu   |   Vòng không có công thức hữu ích. Cảm ơn !
Siêu tra cứu: Nhiều tiêu chí VLookup    VLookup Nhiều Giá Trị  |   VLookup trên nhiều trang tính   |   Tra cứu mờ ....
Danh sách thả xuống nâng cao: Tạo nhanh danh sách thả xuống   |  Danh sách thả xuống phụ thuộc   |  Danh sách thả xuống nhiều lựa chọn ....
Trình quản lý cột: Thêm một số cột cụ thể  |  Di chuyển cột  |  Chuyển đổi trạng thái hiển thị của các cột ẩn  |  So sánh dãy và cột hữu ích. Cảm ơn !
Các tính năng nổi bật: Tiêu điểm lưới   |  Chế độ xem thiết kế   |   Thanh công thức lớn    Trình quản lý sổ làm việc & trang tính   |  Thư viện tài nguyên (Văn bản tự động)   |  Bảng chọn ngày   |  Kết hợp các bảng tính   |  Mã hóa/Giải mã ô    Gửi email theo danh sách   |  Siêu lọc   |   Bộ lọc đặc biệt (lọc in đậm/nghiêng/gạch ngang...) ...
15 bộ công cụ hàng đầu12 bản văn CÔNG CỤ (thêm văn bản, Xóa ký tự,...)   |   50 + Biểu đồ Các loại (Biểu đồ Gantt,...)   |   40+ Thực tế Công thức (Tính tuổi dựa trên ngày sinh,...)   |   19 chèn CÔNG CỤ (Chèn mã QR, Chèn ảnh từ đường dẫn,...)   |   12 Chuyển đổi CÔNG CỤ (Số thành từ, Chuyển đổi tiền tệ,...)   |   7 Hợp nhất & Tách CÔNG CỤ (Các hàng kết hợp nâng cao, Chia ô,...)   |   ... và nhiều hơn nữa

Nâng cao kỹ năng Excel của bạn với Kutools for Excel và trải nghiệm hiệu quả hơn bao giờ hết. Kutools for Excel cung cấp hơn 300 tính năng nâng cao để tăng năng suất và tiết kiệm thời gian.  Bấm vào đây để có được tính năng bạn cần nhất...

Mô tả


Tab Office mang lại giao diện Tab cho Office và giúp công việc của bạn trở nên dễ dàng hơn nhiều

  • Cho phép chỉnh sửa và đọc theo thẻ trong Word, Excel, PowerPoint, Publisher, Access, Visio và Project.
  • Mở và tạo nhiều tài liệu trong các tab mới của cùng một cửa sổ, thay vì trong các cửa sổ mới.
  • Tăng 50% năng suất của bạn và giảm hàng trăm cú nhấp chuột cho bạn mỗi ngày!
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