Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 977
  • Last Modified:

Populate column excel using vba

How using VBA  can I populate a column "B" sheet1 with text "AB" to end of row?
0
leezac
Asked:
leezac
  • 5
  • 2
2 Solutions
 
[ fanpages ]IT Services ConsultantCommented:
Hi,

Do you mean you wish for columns [ B ],[C],[D],[E]... to [IV] (Excel 2003) or [XFD] (Excel 2007 onwards) to contain the text "AB"?

If so, this code will apply to row 3:

Range(Cells(3&, "B"), Cells(3&, Cells.Columns.Count)) = "AB"

Open in new window


If that is not what you meant, please clarify.  Thank you.

BFN,

fp.
0
 
Shane KahkolaDirector of I.T.Commented:
If you are talking about filling all available cells from column A to the last available column with the text "AB"; here is one way to do it.
    
    Dim r As Range
    Set r = Rows("1:1")
    
    Sheet1.Cells(1, 1) = "AB"
    r.FillRight

Open in new window

If you only want to fill from column A to column AB with some text; here is one way to do that:
    Sheet1.Cells(1, 1) = "Enter Text Here"
    Sheet1.Range("A:AB").FillRight

Open in new window

If you want to request input from the user for the text:
    Sheet1.Cells(1, 1) = InputBox("Enter Text", "Insert")
    Sheet1.Range("A:AB").FillRight

Open in new window

0
 
[ fanpages ]IT Services ConsultantCommented:
I'm glad it wasn't just me that had to ask about the question! :)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leezacAuthor Commented:
I just actually want to populate sheet19 only column W down to end of last used row in column A...

Does that help?
0
 
[ fanpages ]IT Services ConsultantCommented:
How using VBA  can I populate a column "B" sheet1 with text "AB" to end of row?
I just actually want to populate sheet19 only column W down to end of last used row in column A...

Does that help?

It depends... if we ask again will the question be something different?
0
 
[ fanpages ]IT Services ConsultantCommented:
Assuming [Sheet19] is active (selected):

Range(Cells(1&, "W"), Cells(Cells(Cells.Rows.Count, 1).End(xlUp).Row, "W")) = "AB"

Open in new window


BFN,

fp.
0
 
leezacAuthor Commented:
No, will not change.. ...
0
 
[ fanpages ]IT Services ConsultantCommented:
In that case, please use the suggestion posted in comment ID: 39186001.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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