ROW CELLS SHOULD HAVE VALUE WHEN WORKBOOK OPEN

K

K

Hi all, I need macro that when i open my Workbook i should have (see
below)

in row 2 cells from coloumn A to C
cell A2 value = "KK"
cell B2 value = "Ford"
cell C2 value= "VR"

and when i open my workbook again now i should get same thing but in
row 3 and it should continue when ever i open my workbook until row
10. And when in row 10 from column A to C i have values in cells A10 ,
B10 and C10 (the values metioned above) i should not get anything in
row 11 and now when ever i'll open my workbook macro should exit . in
other words i want macro to put values when ever i open the workbook
in each row cells form coloumn A to C and once cell A10 to C10 in row
10 have values now macro should exit and not donot do any thing. I
hope i was able to expalin my question. Please can any friend can help
 
M

Mike H

Hi,

If I've understood correctly, try this. Alt+F11 to open Vb editor. Double
click 'This Workbook' and paste this in on the right.

Private Sub Workbook_Open()
Lastrow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
If Lastrow < 10 Then
With Sheets("Sheet1")
.Range("A" & Lastrow + 1).Value = "KK"
.Range("B" & Lastrow + 1).Value = "Ford"
.Range("C" & Lastrow + 1).Value = "VR"
End With
End If
End Sub

Mike
 
K

K

Hi,

If I've understood correctly, try this. Alt+F11 to open Vb editor. Double
click 'This Workbook' and paste this in on the right.

Private Sub Workbook_Open()
Lastrow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
If Lastrow < 10 Then
        With Sheets("Sheet1")
            .Range("A" & Lastrow + 1).Value = "KK"
            .Range("B" & Lastrow + 1).Value = "Ford"
            .Range("C" & Lastrow + 1).Value = "VR"
        End With
End If
End Sub

Mike







- Show quoted text -


Yes this is what i was looking for. Thanks Mike H
 
R

Rick Rothstein \(MVP - VB\)

Just for the archive, here is a slightly different way to do the same
thing...

Private Sub Workbook_Open()
Dim EmptyRow As Long
With Sheets("Sheet1")
EmptyRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
If EmptyRow <= 10 Then
.Range("A" & EmptyRow).Resize(1, 3).Value = Array("KK", "Ford", "VR")
End If
End With
End Sub

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top