问题描述
Private Sub CommandButton1_Click()
Dim myFile As String
Dim wb As Workbook
Dim ws As Worksheet
curRow = 1
Dim maxRow As Integer
Dim copySuburb As String
myFile = Application.GetopenFilename(,"browse Workbook")
Set wb = Workbooks.Open(myFile)
wb.Activate
Set ws = wb.Sheets(1)
ws.Range("BB:AX,AV:AR,AQ:AL,AA:AK,X:W,U:T,N:O,L:B").Delete
ws.Rows(3).EntireRow.Delete
ws.Rows(2).EntireRow.Delete
ws.Rows(1).EntireRow.Delete
maxRow = ws.UsedRange.Rows.Count
ws.Rows(maxRow).EntireRow.Delete
ws.Rows(maxRow - 1).EntireRow.Delete
ws.Rows(maxRow - 2).EntireRow.Delete
maxRow = ws.UsedRange.EntireRow.Count
With ActiveWorkbook.ActiveSheet.sort
.sortFields.Clear
.sortFields.Add Key:=Range("A1:A" & Rows.Count),Order:=xlAscending
.sortFields.Add Key:=Range("B1:B" & Rows.Count),Order:=xlAscending
.SetRange Range("A1:I" & Rows.Count)
.Header = xlNo
.Apply
End With
Do Until ws.Range("A" & curRow).Value = vbNullString
ws.Rows(curRow + 1).Insert shift:=xlShiftDown
ws.Range("C" & curRow).Value = ws.Range("D" & curRow - 1).Value
curRow = curRow + 2
Loop
End Sub
这是我的代码。我的问题是我在显示ws.Range("C" & curRow).Value = ws.Range("D" & curRow - 1).Value
我要做的就是将位于D列的单元格的值复制到C(不同的行)。我浏览了导致此错误的原因的互联网,我怀疑当前正在使用的工作表不是活动的?感谢您的帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)