난 당신이 다른 컬럼 그냥 문자 참조를 변경하려는 경우 당신이 열 B에서 열 A TextBox3
및 ComboBox1
을 원하는 가정입니다.
Sub OnClick() 'whatever your current sub is called.
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("Name of Sheet where data is going")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1 'Finds the last blank row
ws.Range("A" & LastRow).Value = TextBox3.Text 'Adds the TextBox3 into Col A & Last Blank Row
ws.Range("B" & LastRow).Value = ComboBox1.Text 'Adds the ComboBox1 into Col B & Last Blank Row
End Sub
당신은 Offset()
사용하는 방법하려면 다음의
Sub OnClickwithOffset() 'whatever your current sub is called.
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("Name of Sheet where data is going")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1 'Finds the last blank row
ws.Range("A" & LastRow).Value = TextBox3.Text 'Adds the TextBox3 into Col A & Last Blank Row
ws.Range("A" & LastRow).Offset(0, 1).Value = ComboBox1.Text 'Adds the ComboBox1 into next cell to the right of TextBox3 data.
End Sub
가능한 중복 (http://stackoverflow.com/questions/10714251/how- [엑셀 VBA 매크로의 선택 사용하지 않는 방법] to-avoid-using-select-in-excel-vba-macros) –
잘못된 것은 아닙니다! 매크로를 기록하고 그대로 사용하십시오. 그것은 당신을 위해 작동하고, 그러므로, 그것은 괜찮습니다. 그것은 정말로 프로그래밍이 아니지만 왜 신경을 씁니까? 또한 적은 수의 라인이 그 자체로 좋거나 나쁘지 않고 단지 적은 수입니다. 읽을 수 있으면 OK입니다. –
질문에 대답하기 위해서 우리는 다음을 알아야합니다 :'TextBox3'을 덤프하기를 원하는 셀,'ComboBox1'을 덤프하기를 원하는 셀 (TextBox3 셀에서'Offset (0, 1)'처럼 보임)) 그리고'Offset (1, -1)'셀을 가지고 무엇을하려 하는가. (편집 : 신경 쓰지 마라. 다음 빈 줄에 항목을 추가한다.) – Chrismas007