snasui.com ยินดีต้อนรับ
ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
ฟอรัมถาม-ตอบปัญหาการใช้งานสูตรและฟังก์ชัน Excel
Forum rules
ไม่อนุญาตให้ใช้ภาษาแชทในการถามและตอบปัญหา ไม่ใช้คำว่า "คับ" หรือ "อ่ะครับ" แทนคำว่า "ครับ" ไม่ใช้คำว่า "เด๋ว" แทนคำว่า "เดี๋ยว" เป็นต้น เนื่องจากเมื่อแปลเป็นภาษาต่างประเทศแล้วจะให้ความหมายผิดไปจากที่ควรจะเป็น
ห้ามถามโดยระบุชื่อผู้ตอบและต้องตั้งชื่อกระทู้ให้สื่อถึงปัญหาที่จะถาม ไม่ตั้งชื่อว่า ช่วยด้วยครับ, มีปัญหามาปรึกษาครับ เป็นต้น
กรุณาอธิบายปัญหาและระบุคำตอบที่ต้องการมาในกระทู้ด้วยเสมอถึงแม้จะอธิบายไว้ในไฟล์แนบแล้วก็ตาม ทั้งนี้เพื่ออำนวยความสะดวกแก่เพื่อนสมาชิกในการค้นหาข้อมูล
กรุณาแนบไฟล์ตัวอย่างพร้อมแสดงคำตอบที่ถูกต้องมาในไฟล์ด้วยเพื่อให้ง่ายต่อการทำความเข้าใจและสะดวกต่อการตอบคำถาม (ขนาดไฟล์ไม่เกิน 500Kb ขนาดภาพไม่เกิน 800*600 Pixel) ไม่แนบเป็น Link มาจากแหล่งอื่นที่อาจจะถูกลบทิ้งไปโดยต้นทางในภายหลัง นอกจากนี้ไม่ควรแนบไฟล์ที่มีข้อมูลสำคัญอันก่อให้เกิดความเสียหายกับตนเองและผู้อื่น
กรณีเป็นคำถามเกี่ยวกับ Programming เช่น VBA, VB.Net, C#, SQL ฯลฯ ต้องลองเขียนมาเองก่อนเสมอ ถามเฉพาะที่ติดปัญหา ระบุ Module, Procedure ที่ติดปัญหาให้ชัดเจน กรุณาโพสต์ Code ให้แสดงเป็น Code คือเปิดด้วย [code] และปิดด้วย [/code] ตัวอย่างเช่น [code]dim r as range[/code] เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)
กรุณาแจ้งผลการใช้งานเมื่อได้รับคำตอบว่าตรงกับความต้องการหรือไม่
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#1
Post
by sna » Wed Oct 07, 2020 6:27 pm
Hi Dear
I have an issue I need to copy data from sheet Reconcile Txn to Backup Sheet but not empty.
what should I add or edit my code to do that?
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#2
Post
by sna » Wed Oct 07, 2020 6:29 pm
Please refer to this template .I also need your help how to clear data more dynamic(Module 1 and 2)
Thanks
You do not have the required permissions to view the files attached to this post.
snasui
Site Admin
Posts: 31253 Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:
#3
Post
by snasui » Wed Oct 07, 2020 8:43 pm
The example code is below:
Code: Select all
Sub CL()
'RCL2.[A6:Y100].ClearContents
With RCL2
.Range("a6:y" & .Range("a" & .Rows.Count).End(xlUp).Row).ClearContents
End With
End Sub
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#4
Post
by sna » Wed Oct 07, 2020 10:27 pm
thank how about copy and paste without blank rows in Module 3?
snasui
Site Admin
Posts: 31253 Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:
#5
Post
by snasui » Wed Oct 07, 2020 10:52 pm
The example code is below:
Code: Select all
With RCL1
r = [Sumproduct(--('RECONCILE TXN'!b12:b100<>""))]
.Range("b12:z12").Resize(r).Copy
RCL4.Range("a1").PasteSpecial xlPasteValues
End With
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#6
Post
by sna » Thu Oct 08, 2020 7:55 am
Thank you
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#7
Post
by sna » Thu Oct 08, 2020 8:52 pm
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
Range("B" & Target.Row).Resize(, 20).Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End Sub
your code work fine,is it possible like this??
or we can use special cell constant?
Thank you once again
snasui
Site Admin
Posts: 31253 Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:
#8
Post
by snasui » Fri Oct 09, 2020 6:28 am
It possible to do everything with code. Try with yourself for your task, post the error and attach file to here.
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#9
Post
by sna » Fri Oct 09, 2020 7:32 am
Thank you
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#10
Post
by sna » Fri Oct 09, 2020 12:11 pm
I test
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
Range("B" & Target.Row).Resize(1, 20).Copy RCL4.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End Sub
it is not working !
snasui
Site Admin
Posts: 31253 Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:
#11
Post
by snasui » Sat Oct 10, 2020 6:58 am
You need to post code with code style such as post #7.
Attach the updated file that have your latest code inside and explain what you want to do and point to the expected result from your code.
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#12
Post
by sna » Sat Oct 10, 2020 8:37 am
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
Range("B" & Target.Row).Resize(, 20).Copy RCL4.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End Sub
I need to copy from RCL1 to RCL4 without empty cells
Best wishes
snasui
Site Admin
Posts: 31253 Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:
#13
Post
by snasui » Sat Oct 10, 2020 9:30 am
snasui wrote: Sat Oct 10, 2020 6:58 am
Attach the updated file that have your latest code inside and explain what you want to do and point to the expected result from your code.
Please read my post above carefully.
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#14
Post
by sna » Sat Oct 10, 2020 11:50 am
Here's the attached file for your reference
Thanks
You do not have the required permissions to view the files attached to this post.
snasui
Site Admin
Posts: 31253 Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 2019
Contact:
#15
Post
by snasui » Sat Oct 10, 2020 2:11 pm
You can call 'CopyNonBlankValue' as below.
Code: Select all
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
' Range("B" & Target.Row).Resize(, 24).Copy RCL4.Cells(Rows.Count).End(xlUp).Offset(1)
Call Module3.CopyNonBlankValue
End Sub
sna
Silver
Posts: 721 Joined: Tue May 05, 2020 8:18 am
Excel Ver: Excel 365
#16
Post
by sna » Sat Oct 10, 2020 4:30 pm
Ok.thank will update you