오빠두 선생님의 DB 함수 응용 방법을 알려주세요.
VBA
작성자
황금감자
작성일
2022-10-19 19:26
조회
990
이 부분에 대하여 질문드립니다...
Product 를 눌러서 제품을 추가,삭제,수정하거나 또는 제품을 검색하고 클릭하여 "C10"부터 자료가 붙여넣기
되고 그 뒤에 다시 반복작업을 할 경우, "C10"에 입력이 됬으니 그 아래 "C11"행에 아래로 누적되어 입력되게
자료를 만들려고 하는데
__________________________________________________________
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets("고객명")
Insert_Record WS, "값1", "값2", "값3", ...
____________________________________________________________
이 부분을 사용하면 될까요?
어떻게 입력하면 좋을까요? 예를들어 카테고리 1번, 카레고리 2번은 제외한 나머지만 붙여넣기를 한다면요.
사진과 수식 첨부 드립니다.
Private Sub P_B_C1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) frmCategory1.Show End Sub Private Sub P_B_C2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) frmCategory2.Show End Sub Private Sub P_B_C3_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) frmCategory3.Show End Sub Private Sub P_B_C4_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) frmCategory4.Show End Sub Private Sub P_B_UOM_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) frmUOM.Show End Sub Private Sub P_B_Close_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Unload Me End Sub Private Sub P_B_Close_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then Unload Me End Sub Private Sub P_B_Delete_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) P_Delete End Sub Private Sub P_B_Delete_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then P_B_Delete End Sub Private Sub P_B_Modify_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) P_Modify End Sub Private Sub P_B_Modify_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then P_B_Modify End Sub Private Sub P_B_Register_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) P_Register End Sub Private Sub P_B_Register_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then P_Register End Sub Private Sub P_B_Reset_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) P_Reset End Sub Private Sub P_B_Reset_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then P_Reset End Sub Private Sub txt_P_Search_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 27 Then Unload Me End Sub '유저폼에 추가한 버튼에 개수만큼 아래 명령문을 유저폼에 추가한 뒤, btnXXX 를 버튼 이름으로 변경합니다. Private Sub P_B_Delete_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_Delete End Sub Private Sub P_B_Delete_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_Delete End Sub Private Sub P_B_Reset_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_Reset End Sub Private Sub P_B_Reset_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_Reset End Sub Private Sub P_B_Register_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_Register End Sub Private Sub P_B_Register_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_Register End Sub Private Sub P_B_Modify_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_Modify End Sub Private Sub P_B_Modify_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_Modify End Sub Private Sub P_B_Close_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_Close End Sub Private Sub P_B_Close_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_Close End Sub Private Sub P_B_Select_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_Select End Sub Private Sub P_B_Select_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_Select End Sub Private Sub P_B_C1_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_C1 End Sub Private Sub P_B_C1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OutHover_Css Me.P_B_C1 End Sub Private Sub P_B_C2_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_C2 End Sub Private Sub P_B_C2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_C2 End Sub Private Sub P_B_C3_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_C3 End Sub Private Sub P_B_C3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_C3 End Sub Private Sub P_B_C4_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_C4 End Sub Private Sub P_B_C4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_C4 End Sub Private Sub P_B_UOM_Exit(ByVal Cancel As MSForms.ReturnBoolean) OutHover_Css Me.P_B_UOM End Sub Private Sub P_B_UOM_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) OnHover_Css Me.P_B_UOM End Sub Private Sub btnXXX_Enter() OnHover_Css Me.btnXXX End Sub '아래 코드를 유저폼에 추가한 뒤, "btnXXX, btnYYY"를 버튼이름을 쉼표로 구분한 값으로 변경합니다. Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Dim ctl As Control Dim btnList As String: btnList = "P_B_Delete, P_B_Reset, P_B_Register, P_B_Modify, P_B_Close, P_B_Select, P_B_C1, P_B_C2, P_B_C3, P_B_C4, P_B_UOM" ' 버튼 이름을 쉼표로 구분하여 입력하세요. Dim vLists As Variant: Dim vList As Variant If InStr(1, btnList, ",") > 0 Then vLists = Split(btnList, ",") Else vLists = Array(btnList) For Each ctl In Me.Controls For Each vList In vLists If InStr(1, ctl.Name, Trim(vList)) > 0 Then OutHover_Css ctl Next Next End Sub '커서 이동시 버튼 색깔을 변경하는 보조명령문을 유저폼에 추가합니다. Private Sub OnHover_Css(lbl As Control): With lbl: .BackColor = RGB(211, 240, 224): .BorderColor = RGB(134, 191, 160): End With: End Sub Private Sub OutHover_Css(lbl As Control): With lbl: .BackColor = &H8000000E: .BorderColor = -2147483638: End With: End Sub Sub P_Reset() Clear_Ctrls Me, "txt*", "txt_P_NameID,P_Search,P_ListBox" End Sub Sub P_Modify() Dim DB As Variant DB = Get_DB(ShtProduct) Update_Record ShtProduct, Me.txtID.Value, Me.txt_P_Name01.Value, Me.txt_P_ComboBox02.Value, _ Me.txt_P_ComboBox03.Value, Me.txt_P_ComboBox04.Value, Me.txt_P_ComboBox05.Value, _ txt_P_Name06.Value, txt_P_Name07.Value, txt_P_Name08.Value, txt_P_Name09.Value, _ txt_P_ComboBox10.Value, txt_P_Name11.Value Update_lstMain Select_ListItm Me.P_ListBox, Me.txtID.Value End Sub Sub P_Register() Dim DB As Variant Dim blnUnique As Boolean 'True/False DB = Get_DB(ShtProduct) blnUnique = IsUnique(DB, Me.txt_P_Name01.Value, 2) If blnUnique = False Then MsgBox "The same code exists. Please check again.", vbExclamation: Exit Sub Insert_Record ShtProduct, Me.txt_P_Name01.Value, Me.txt_P_ComboBox02.Value, _ Me.txt_P_ComboBox03.Value, Me.txt_P_ComboBox04.Value, Me.txt_P_ComboBox05.Value, _ txt_P_Name06.Value, txt_P_Name07.Value, txt_P_Name08.Value, txt_P_Name09.Value, _ txt_P_ComboBox10.Value, txt_P_Name11.Value Update_lstMain P_Reset MsgBox "The product has been registered.", vbInformation End Sub Private Sub P_ListBox_Click() Click_P_ListBox End Sub Private Sub UserForm_Initialize() Update_lstMain Update_UOM Update_Category1 Update_Category2 Update_Category3 Update_Category4 End Sub Sub Click_P_ListBox() Dim vArr As Variant vArr = Get_ListItm(Me.P_ListBox) Me.txtID.Value = vArr(0) Me.txt_P_Name01.Value = vArr(1) Select_CboItm Me.txt_P_ComboBox02, vArr(2) Select_CboItm Me.txt_P_ComboBox03, vArr(3) Select_CboItm Me.txt_P_ComboBox04, vArr(4) Select_CboItm Me.txt_P_ComboBox05, vArr(5) Me.txt_P_Name06.Value = vArr(6) Me.txt_P_Name07.Value = vArr(7) Me.txt_P_Name08.Value = vArr(8) Me.txt_P_Name09.Value = vArr(9) Select_CboItm Me.txt_P_ComboBox10, vArr(10) Me.txt_P_Name11.Value = vArr(11) End Sub Sub Update_lstMain() Dim DB As Variant DB = Get_DB(ShtProduct) DB = Connect_DB(DB, 2, ShtP_Ca1, "Category1") DB = Connect_DB(DB, 3, ShtP_Ca2, "Category2") DB = Connect_DB(DB, 4, ShtP_Ca3, "Category3") DB = Connect_DB(DB, 5, ShtP_Ca4, "Category4") Update_List Me.P_ListBox, DB, "0;80;0;0;0;0;100;170;170;50;50;50;100;60;60;60" End Sub Sub Update_UOM() Dim DB As Variant DB = Get_DB(ShtUOM, True) Update_Cbo Me.txt_P_ComboBox10, DB End Sub Sub Update_Category1() Dim DB As Variant DB = Get_DB(ShtP_Ca1) Update_Cbo Me.txt_P_ComboBox02, DB, 2 End Sub Sub Update_Category2() Dim DB As Variant DB = Get_DB(ShtP_Ca2) Update_Cbo Me.txt_P_ComboBox03, DB, 2 End Sub Sub Update_Category3() Dim DB As Variant DB = Get_DB(ShtP_Ca3) Update_Cbo Me.txt_P_ComboBox04, DB, 2 End Sub Sub Update_Category4() Dim DB As Variant DB = Get_DB(ShtP_Ca4) Update_Cbo Me.txt_P_ComboBox05, DB, 2 End Sub
전체 0
댓글을 남기려면 로그인하세요.
전체 18,532
번호 | 카테고리 | 제목 | 작성자 | 작성일 | 추천 | 조회 |
[📚진짜쓰는 실무엑셀] IT/오피스 '1위' 베스트셀러! 엑셀 공부, 이 교재로 마스터하세요! (315)
![]() ![]() |
![]() ![]() |
2022.02.03 | 575 | 609495 | ||
공지사항 | 문서서식 |
⭐ [더 나은 커뮤니티 문화를 위한 Q&A 글 작성 규칙] ⭐
(197)
오빠두엑셀
|
2021.10.28
|
추천 310
|
조회 35540
|
![]() ![]() |
2021.10.28 | 310 | 35540 |
78582 | 함수/공식 |
New 조건 함수 의 관한 문의
![]() ![]() ![]() |
![]() |
15:46 | - | 14 |
78580 |
New 날짜와 시간 분할 방법 알려 주세요
![]() ![]() ![]() |
![]() |
15:14 | - | 15 | |
78575 | VBA |
New 엑셀 재고관리 프로그램 문의드립니다..
![]() ![]() |
![]() |
04:23 | - | 58 |
78570 | 대시보드 |
New 대시보드에 표 형식으로 표현도 가능한가요?
![]() ![]() |
![]() |
2025.05.12 | - | 63 |
78569 | 함수/공식 |
New 서로 다른 양식의 견적서 엑셀 파일 한곳에 정리 하기
(5)
![]() |
![]() |
2025.05.12 | - | 83 |
78565 | 함수/공식 |
New 검색보고서 만들기 질문드립니다.
![]() ![]() |
![]() |
2025.05.12 | - | 79 |
78563 | VBA |
New VBA 수정 부탁드립니다. ㅠ
(3)
![]() |
![]() |
2025.05.12 | - | 69 |
78560 | 함수/공식 |
New 어떻게 내용을 가져올수 있을지 고수님들의 해결방법들을 공유 받고 싶습니다!!....
![]() ![]() ![]() |
![]() |
2025.05.12 | - | 43 |
78559 | 파워쿼리/피벗 |
New 엑셀 자동화 질문 입니다...
![]() ![]() |
![]() |
2025.05.12 | - | 62 |
78555 | 함수/공식 |
New 시트에서 원하는 열의 자료만 가져오고싶은데 아무리 해도 수식오류가 나서 도움을 구하고자 합니다
![]() ![]() |
![]() |
2025.05.12 | - | 41 |
78554 | 함수/공식 |
New 변동하는 절대참조값 적용
(6)
답변완료
![]() |
![]() |
2025.05.12 | - | 62 |
78553 | 대시보드 |
New 대시보드_슬라이서 자동으로 눌러지게 하는방법
![]() ![]() |
![]() |
2025.05.12 | - | 45 |
78548 | 대시보드 |
New 어떤 엑셀을 적용해야하는 지 문의드립니다!
(1)
![]() |
![]() |
2025.05.11 | - | 63 |
78546 | 함수/공식 |
New 월별 매출액 자동입력할 수 있는 방법 또는 함수 궁금합니다!
![]() ![]() |
![]() |
2025.05.11 | - | 84 |
78544 | 함수/공식 |
New 중복값 제거 함수에 관하여
![]() ![]() ![]() |
![]() |
2025.05.11 | - | 71 |
78543 | 함수/공식 |
New 데이터 추출 및 정렬관련 초보질문
![]() ![]() ![]() |
![]() |
2025.05.11 | - | 64 |
78540 | 함수/공식 |
New 오빠두LIVE 219회 - 엑셀 '셀 병합' 자동화 보고서 만들기 오빠두엑셀님의 방법이 궁금합니다.
![]() ![]() |
![]() |
2025.05.10 | - | 56 |
78536 | 함수/공식 |
New 월별로 금액적용후 최종월에 차액을 가감 함수가 필요해요
![]() ![]() |
![]() |
2025.05.10 | - | 61 |
78535 | 기능/도구 |
New 엑셀로 25x25 인쇄가 가능한가요?
(1)
![]() |
![]() |
2025.05.10 | - | 47 |
78534 | 파워쿼리/피벗 |
New 쿼리에 함수 적용한 열 추가 시 24:00:00 활용한 계산 함수 필요할 때.
![]() ![]() |
![]() |
2025.05.10 | - | 60 |
78531 | 차트/그래프 |
New 엑셀 차트 데이터테이블
![]() ![]() ![]() |
![]() |
2025.05.09 | - | 69 |
78530 | 구글시트 |
New 구글 스프레드시트 함수 관련 질문입니다.
![]() ![]() ![]() |
![]() |
2025.05.09 | - | 60 |
78528 | 구글시트 |
New 구글 스프레드시트를 외부 엑셀 파일과 연동하는 방법이 궁금합니다.
(3)
![]() |
![]() |
2025.05.09 | - | 64 |
78525 | 문서서식 |
New 업무가 진행이 안 될 정도로, 해당 파일이 느립니다!
![]() ![]() |
![]() |
2025.05.09 | - | 88 |
78520 | 기능/도구 |
New 하이퍼링크 명칭 해제
(1)
![]() |
![]() |
2025.05.09 | - | 49 |
78518 | 피벗테이블 |
New 피벗테이블 관련 화살표 질문
![]() ![]() |
![]() |
2025.05.09 | - | 47 |
78516 | 함수/공식 |
New 호봉산정 엑셀 문의드립니다.
![]() ![]() ![]() |
![]() |
2025.05.08 | - | 55 |
78515 | 함수/공식 |
New 엑셀 질문 드립니다.ㅠ.ㅠ
![]() ![]() |
![]() |
2025.05.08 | - | 50 |
78511 | 함수/공식 |
New 입사일자로 부터 매년 알림
(2)
![]() |
![]() |
2025.05.08 | - | 66 |
78510 | 문서서식 |
New 조건부 서식 적용 문의
![]() ![]() ![]() |
![]() |
2025.05.08 | - | 96 |