Selasa, 08 Juli 2014

Re: [ExcelVBA] Need help with sequential line numbering

 

Hi I think your problem is that you're thinking active cell is in the new row. Try your formula with active cell still the old row

On 8 Jul 2014 20:39, "jefff@rogers.com [ExcelVBA]" <ExcelVBA@yahoogroups.com> wrote:
 

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: Ralph Gregory <ralph.gregory@skaino.co.uk>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)
----------------------------------
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