Solved

Populate column excel using vba

Posted on 2013-05-21
8
887 Views
Last Modified: 2013-05-22
How using VBA  can I populate a column "B" sheet1 with text "AB" to end of row?
0
Comment
Question by:leezac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39185865
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
 
LVL 3

Assisted Solution

by:Shane Kahkola
Shane Kahkola earned 100 total points
ID: 39185866
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
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39185869
I'm glad it wasn't just me that had to ask about the question! :)
0
Independent Software Vendors: 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!

 

Author Comment

by:leezac
ID: 39185912
I just actually want to populate sheet19 only column W down to end of last used row in column A...

Does that help?
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39185994
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
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 400 total points
ID: 39186001
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
 

Author Comment

by:leezac
ID: 39186004
No, will not change.. ...
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39186021
In that case, please use the suggestion posted in comment ID: 39186001.
0

Featured Post

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question