如何删除单元格并向上移动数据而不是ritetoleft [英] How can I delete a cell and move the data upward and not ritetoleft
本文介绍了如何删除单元格并向上移动数据而不是ritetoleft的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim appXL As Excel.Application
Dim wbXl As Excel.Workbook
Dim shXL As Excel.Worksheet
Dim raXL As Excel.Range
appXL = CreateObject("Excel.Application")
appXL.Visible = True
wbXl = appXL.Workbooks.Add
shXL = wbXl.ActiveSheet
With shXL.Range("A1", "D1")
.Font.Bold = True
.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
End With
Dim students(5, 2) As String
students(0, 0) = "zero , zero"
students(0, 1) = "zero , one"
students(1, 0) = "one, zero"
students(1, 1) = "one, one"
students(2, 0) = "two ,zero"
students(2, 1) = "two, one"
students(3, 0) = "Three, zero"
students(3, 1) = "three, one"
students(4, 0) = "four, zero"
students(4, 1) = "four, one"
' Fill A2:B6 with an array of values (First and Last Names).
shXL.Range("A2", "B6").Value = students
' Fill C2:C6 with a relative formula (=A2 & " " & B2).
raXL = shXL.Range("C2", "C6")
raXL.Formula = "=A2 & "" "" & B2"
raXL = shXL.Range("A1", "D1")
raXL.EntireColumn.AutoFit()
appXL.Visible = True
appXL.UserControl = True
raXL = Nothing
shXL = Nothing
wbXl = Nothing
appXL.Quit()
appXL = Nothing
Exit Sub
Err_Handler:
MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
End Sub
End Class
我是什么尝试过:
如何删除一个单元格并向上移动数据而不是向左移动
现在在你之后保存更改excel以便您可以删除一个单元格并将数据向上移动
向上而不是向左移动
在很多网站上都有答案但是它不起作用为什么?
What I have tried:
how can i delete a cell and move the data upward and not rite to left
now after you save change the excel so that you can delete a cell and shift the data
upward and not rite to left
in many web there is a answer but it don`t work why?
推荐答案
参见 Range.Delete方法(Microsoft.Office.Interop.Excel) [ ^ ]。
这篇关于如何删除单元格并向上移动数据而不是ritetoleft的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文