Selasa, 08 Juli 2014

[ExcelVBA] Need help with sequential line numbering

 

Hi All Experts,
I am trying to create a VBA program that will insert a new line and will populate column A with sequential line numbering based on the previous line numbers' value. Please do not confuse line number with row number, as there are some rows at the top that will contain static text data. Here is my attempt so far, but I am getting a "Run-time Error 13 type mismatch" in the last line of code. Any help is appreciated.

Option Explicit

Private Sub cmdTransferData_Click()
   
    Dim EmptyRow As Long
   
    EmptyRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 1).Row

'Insert Row
    Cells(EmptyRow, 1).Rows("1:1").EntireRow.Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
   
'Number First Cell In Row
    Cells(EmptyRow, 1).Select
    ActiveCell.Value = ActiveCell.Offset(-1, 0) + 1


__._,_.___

Posted by: jefff@rogers.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar