:D snasui.com ยินดีต้อนรับ :D
ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย :thup: สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ :arrow: ระบุ Version ของ Excel
:!: โปรดทราบ :!:
  1. กรุณาอ่านกฎการใช้บอร์ด (Forum rules) ในตำแหน่งด้านบนของแต่ละบอร์ด
  2. การสมัครสมาชิก การ Login การกู้คืนรหัสผ่าน
    1. สมัครสมาชิกดูขั้นตอนได้ที่ :arrow: สมัครสมาชิก
    2. Login เข้าระบบโดยคลิกปุ่ม Login ตรงมุมขวาบนของหน้านี้ :roll:
    3. การ Login ผ่าน Facebook ดูวิธีที่ :arrow: Login ผ่าน Facebook
    4. ลืมรหัสผ่านสามารถรับรหัสใหม่ได้ที่ :arrow: Reset รหัสผ่าน
  3. มีปัญหาการใช้งาน แจ้งผู้ดูแลระบบได้ที่ :arrow: ติดต่อผู้ดูแลระบบ
  4. กำหนดการตั้งค่าส่วนตัว เช่นตั้งค่าภาษาเป็นไทยหรืออังกฤษดูได้ที่ :arrow: ตั้งค่าส่วนตัว
  5. การตั้งและตอบกระทู้ดูได้ที่ :arrow: วิธีการตั้งและตอบกระทู้
  6. การจัดรูปแบบตัวอักษรด้วย bbcode ในช่องแสดงความคิดเห็นดูได้ที่ :arrow: จัดรูปแบบตัวอักษร
  7. กำหนดขนาดตัวอักษรใน Browser ดูได้ที่ :arrow: กำหนดขนาดตัวอักษรใน Browser

code help

ฟอรัมถาม-ตอบปัญหาการใช้งาน MS Excel and VBA
Forum rules
  1. ไม่อนุญาตให้ใช้ภาษาแชทในการถามและตอบปัญหา ไม่ใช้คำว่า "คับ" หรือ "อ่ะครับ" แทนคำว่า "ครับ" ไม่ใช้คำว่า "เด๋ว" แทนคำว่า "เดี๋ยว" เป็นต้น เนื่องจากเมื่อแปลเป็นภาษาต่างประเทศแล้วจะให้ความหมายผิดไปจากที่ควรจะเป็น
  2. ห้ามถามโดยระบุชื่อผู้ตอบและต้องตั้งชื่อกระทู้ให้สื่อถึงปัญหาที่จะถาม ไม่ตั้งชื่อว่า ช่วยด้วยครับ, มีปัญหามาปรึกษาครับ เป็นต้น
  3. กรุณาอธิบายปัญหาและระบุคำตอบที่ต้องการมาในกระทู้ด้วยเสมอถึงแม้จะอธิบายไว้ในไฟล์แนบแล้วก็ตาม ทั้งนี้เพื่ออำนวยความสะดวกแก่เพื่อนสมาชิกในการค้นหาข้อมูล
  4. กรุณาแนบไฟล์ตัวอย่างพร้อมแสดงคำตอบที่ถูกต้องมาในไฟล์ด้วยเพื่อให้ง่ายต่อการทำความเข้าใจและสะดวกต่อการตอบคำถาม (ขนาดไฟล์ไม่เกิน 500Kb ขนาดภาพไม่เกิน 800*600 Pixel) ไม่แนบเป็น Link มาจากแหล่งอื่นที่อาจจะถูกลบทิ้งไปโดยต้นทางในภายหลัง นอกจากนี้ไม่ควรแนบไฟล์ที่มีข้อมูลสำคัญอันก่อให้เกิดความเสียหายกับตนเองและผู้อื่น
  5. กรณีเป็นคำถามเกี่ยวกับ Programming เช่น VBA, VB.Net, C#, SQL ฯลฯ ต้องลองเขียนมาเองก่อนเสมอ ถามเฉพาะที่ติดปัญหา ระบุ Module, Procedure ที่ติดปัญหาให้ชัดเจน กรุณาโพสต์ Code ให้แสดงเป็น Code คือเปิดด้วย [code] และปิดด้วย [/code] ตัวอย่างเช่น [code]dim r as range[/code] เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)
  6. กรุณาแจ้งผลการใช้งานเมื่อได้รับคำตอบว่าตรงกับความต้องการหรือไม่
sna
Silver
Silver
Posts: 640
Joined: Tue May 05, 2020 8:18 am
Excel Ver: 2013,2016

code help

#1

Post by sna »

Hi dear
I have this 2 sheets where in the expected purchases sheet row2, I got the values with the help of formulas connected to the already existing 2 sheets. I need your expertise to convert the formulas into code and get the data in Purchases sheet. The code to create the purchases sheet with headings is working.
with the help of a code, insert formulas in each column as shown in the purchases sheet row2
resize the data in Purchases with 2B
The new created purchases sheet should match the expected result as shown without the formulas.
Thank you in advance.
sna
Silver
Silver
Posts: 640
Joined: Tue May 05, 2020 8:18 am
Excel Ver: 2013,2016

Re: code help

#2

Post by sna »

Cancel
Last edited by sna on Sun Oct 09, 2022 3:53 pm, edited 1 time in total.
sna
Silver
Silver
Posts: 640
Joined: Tue May 05, 2020 8:18 am
Excel Ver: 2013,2016

Re: code help

#3

Post by sna »

Hi there,
Please skip above question,I asked for advice on VBA. Actions to do 1. Separate the data in the L line into Room# and the last name in the M and N lines. 2. Rearrange the sheet "Working" data in the Sheet"MOVECOLUMN" Result: Just press one system and you can do it To the above action question 1 How can I use vba to write the formulas of m and n lines, and then automatically run to the last line with data 2 How to change the formulas to the value in vba in the m and n lines
Last edited by sna on Sun Oct 09, 2022 3:56 pm, edited 1 time in total.
sna
Silver
Silver
Posts: 640
Joined: Tue May 05, 2020 8:18 am
Excel Ver: 2013,2016

Re: code help

#4

Post by sna »

here is a template
You do not have the required permissions to view the files attached to this post.
sna
Silver
Silver
Posts: 640
Joined: Tue May 05, 2020 8:18 am
Excel Ver: 2013,2016

Re: code help

#5

Post by sna »

Hi there,
I need your help how to split text

Code: Select all

Sub SplitText()
    Range("m3").Select
     Do While ActiveCell.Offset(0, -1) <> ""
        ActiveCell = Mid(Split(ActiveCell.Offset(0, -1), "/")(0), 3, 99)
        ActiveCell.Offset(0, 1) = Split(ActiveCell.Offset(0, -1), "/")(1)
        ActiveCell.Offset(1, 0).Range("A1").Select
    Loop
    End Sub
I don't want to loop like this
User avatar
snasui
Site Admin
Site Admin
Posts: 30761
Joined: Sun Jan 24, 2010 12:33 pm
Location: Songkhla, Thailand
Excel Ver: 2010, 365
Contact:

Re: code help

#6

Post by snasui »

:D The example code is below:

Code: Select all

Sub SplitTextAndRearrangeCols()
    Dim rall As Range, r As Range
    Dim rw As Long
    
    With Worksheets("working")
        Set rall = .Range("l3", .Range("l" & .Rows.Count).End(xlUp))
        rw = rall.Rows.Count
        For Each r In rall
            r.Offset(0, 1).Resize(1, 2).Value = VBA.Split(VBA.Replace(r.Value, "Rm", ""), "/")
        Next r
        With Worksheets("movecloumn")
            .Range("a2").Resize(rw).Value = rall.Parent.Range("b3").Resize(rw).Value
            .Range("b2").Resize(rw).Value = rall.Parent.Range("g3").Resize(rw).Value
            .Range("d2").Resize(rw).Value = rall.Parent.Range("c3").Resize(rw).Value
            .Range("e2").Resize(rw).Value = rall.Parent.Range("m3").Resize(rw).Value
            .Range("g2").Resize(rw).Value = rall.Parent.Range("n3").Resize(rw).Value
        End With
    End With
End Sub
sna
Silver
Silver
Posts: 640
Joined: Tue May 05, 2020 8:18 am
Excel Ver: 2013,2016

Re: code help

#7

Post by sna »

Thank you, always awesome 😊
Post Reply