แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - napat2020

หน้า: [1]
1
สวัสดีครับ อจ ทุกท่าน
ผมทำการแยก sheet ด้วย vba excel
ตามกลุ่มของข้อมูลที่เหมือนกัน
มันก็ทำงานได้ปกติ.,.ครับ
 ปัญกาของผมคือ ผมจะต้องมาจัดรูปแบบต่างๆ รวมถึงจัดหน้ากระดาษใหม่ครับ
ถ้าอย่างที่ผมคิดไว้คือ สร้าง sheet
ต้นแบบไว้ แล้วค่อยเอาข้อมูลมาหยอด
จะได้หรือเปล่า และจะต้องแก้ code อย่างไรครับ ผมรบกวนด้วยครับ

โค๊ด: [Select]
Sub SpiltSheet()

On Error Resume Next

'Declaring Constant Variable
 

Application.DisplayAlerts = False

Const col = "A"

Const header_row = ("1:1")

Const starting_row = 2

Dim Source_sheet As Worksheet

Dim destination_sheet As Worksheet

Dim current_sheet As Worksheet

Dim footer_sheet As Worksheet

Dim source_row As Long

Dim last_row As Long

Dim destination_row As Long

Dim Maker As String

'Set source_sheet = ActiveSheet

Set Source_sheet = Sheets("Base")

Set footer_sheet = Sheets("Footer")

 
    last_row = Source_sheet.Cells(Source_sheet.Rows.Count, col).End(xlUp).Row
 

    For source_row = starting_row To last_row

    Maker = Source_sheet.Cells(source_row, col).Value
 

    Set destination_sheet = Nothing

    On Error Resume Next

    Set destination_sheet = Worksheets(Maker)
   

    On Error GoTo 0
   

    If destination_sheet Is Nothing Then

        Set destination_sheet = Worksheets.Add(after:=Worksheets(Worksheets.Count))

        destination_sheet.Name = Maker

   
        'Header

        Source_sheet.Rows(header_row).Copy Destination:=destination_sheet.Rows(header_row)

 
    End If
   

    ' Retrive data

    destination_row = destination_sheet.Cells(destination_sheet.Rows.Count, col).End(xlUp).Row + 1

    Source_sheet.Rows(source_row).Copy Destination:=destination_sheet.Rows(destination_row)
 

    Next source_row

End Sub


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

3
ห้อง MS Access / ความเข้าใจ .Tag code vb access
« เมื่อ: 16 ก.ย. 63 , 22:01:03 »
สวัสดีครับ
ผมมี code ตัวอย่าง ดังนี้ครับ

if txtID.Tag & "" = "" then
   msgbox "ok"
else
   msgbox "ng"
end if

ความหมายของแถวแรกหมายความว่าอย่างไรครับ และ ทำไมใช้ .Tag
คุณสมบัติ .tag คืออะไรครับ

รบกวนครับผม

4
สวัสดีครับ
จากโค้ดด้านล่าง ต้องการลบข้อมูลในตาราง โดยใช้เงื่อนไข อ้างอิงให้ลบจาก
bsCode ขีดเส้นใต้ ซึ่งตอนนี้เป็นข้อมูลชนิดตัวเลข number อยู่ครับ ถ้าต้องการเปลี่ยนข้อมูลชนิดเป็น string จะต้องเขียนอย่างใดครับ
ขอบคุณครับผม
   
 If Not (Me.frmBaseGoodsSub.Form.Recordset.EOF And Me.frmBaseGoodsSub.Form.Recordset.BOF) Then
        If MsgBox(" Are you sure to delete?", vbYesNo) = vbYes Then
            CurrentDb.Execute "DELETE FROM tblBaseGoods " & _
            " WHERE bsCode=" & Me.frmBaseGoodsSub.Form.Recordset.Fields("bsCode")

        End If

     

5
ห้อง MS Access / ใส่ค่าใน textbox อัตโนมัติ
« เมื่อ: 15 ส.ค. 63 , 20:05:34 »
สวัสดีครับอาจารย์ทุกท่าน
รบกวนขอความรู้ด้วยครับผม
 โจทย์ของผมคือ
ผมมี textbox อยู่ 12 ตัว ความต้องการคือ
เมื่อกรอกข้อมูลลง textbox ใดก็ตาม
textbox ถัดไปทั้งหมดจะต้องมีค่าเหมือนกันทั้งหมด ส่วน textbox ก่อนหน้านี้ไม่ต้องเติมข้อมูลใดๆ คือคงค่าไว้
ขอบคุณมากครับผม


6
ห้อง MS Access / หาค่า Min จาก Query Access
« เมื่อ: 17 พ.ค. 63 , 13:15:07 »
เรียนอาจารย์ทุกท่านครับ
ผมรบกวนแนะนำหน่อยครับ
ความต้องการ
ผมมีข้อมูลใน Query  3 Field ดังนี้
Cost_1    Cost_2    Cost_3   CostMin
200        300         400        200
100        500         1500      100
500        700         600        500
ถ้าเป็น Excel ใส่สูตร =Min() ก็จบแล้ว
แต่ถ้าใน Access ไม่มีสูตรนี้ จะต้องเขียน Function ขึ้นมาเอง หรือเปล่าครับ หรือมีวิธีไหนบ้างครับ
ที่สามารถคำนวน ค่า Min ได้ครับ
รบกวนท่านอาจารย์ด้วยครับ

หน้า: [1]