• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 48
  • Last Modified:

Copy Down column

How would I chg this to allow for only one row?  If there is only one row in G it copies Create down the whole column.

Set MyRange = Range(Range("A3"), Range("A" & Range("G3").End(xlDown).Row))
    MyRange.Value = "Create"

Open in new window


Please advise and thanks.
0
RWayneH
Asked:
RWayneH
  • 2
  • 2
1 Solution
 
Saurabh Singh TeotiaCommented:
You can use something like this...

lrow = Cells(3, "g").End(xlDown).Row

If lrow = Cells.Rows.Count Then
Set MyRange = Range("A3:G3")
Else
Set MyRange = Range(Range("A3"), Range("A" & Range("G3").End(xlDown).Row))
End If
 MyRange.Value = "Create"

Open in new window

0
 
RWayneHAuthor Commented:
This copies the word Create across... to G3.  It is only supposed to copy it down as long as there is a value in column G
0
 
Roy CoxGroup Finance ManagerCommented:
If you are using one of the newer versions of Excel then use a Table. Attach a dummy workbook and I'll set it up.
0
 
Saurabh Singh TeotiaCommented:
Change this line..

Set MyRange = Range("A3:G3")

to this...

Set MyRange = Range("A3")

Open in new window

0
 
RWayneHAuthor Commented:
Thanks for the help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now