473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

converting a column of names & addresses to a list of rows

Hello,

I know nothing about VBA and I used the "record macro" feature in excel to get the following macro:

Sub Macro2()
'

'
' Keyboard Shortcut: Ctrl+m
'
Range("A28:A35").Select
Selection.Copy
Range("C1").Select
Selection.End(xlDown).Select
Range("C5").Select
ActiveWindow.SmallScroll Down:=-3
Range("C5").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Selection.End(xlToLeft).Select
Selection.End(xlToRight).Select
Application.CutCopyMode = False
Selection.Copy
Cells.Find(What:=" Thompson John L", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Application.Run "'noteholder list.xls'!Macro2"
End Sub


Instead of going down the list and copying the names & addresses over - it just does the one name.

Range("A28:A35").Select - This should be selecting the active cell down to the end.

Range("C5").Select - This should be selecting the next empty cell in column "C"

Cells.Find(What:=" Thompson John L", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate - This should be what just was pasted in the last "C" column cell.


I hope this is clearer than mud.

I really would like some help
Sep 19 '07 #1
2 1474
kadghar
1,295 Expert 1GB
Hello,

I know nothing about VBA and I used the "record macro" feature in excel to ...
The macro recorder generates a lot of junk and it wont allow you to move free within the ranges. I can explain you what this macro does, but it'll be easier if you tell us what you want to do so we can help you out with your code.

just a few tips before starting:

Range("A28:A35").Select - This should be selecting the active cell down to the end.
No,this will select the range A28 to A35,

if you use the method END this will move you to the left, right, up or down end of that cell (the same effect as Ctrl + arrow)
so if you want to auto select, lets say column A from 28th row to the down end just do:

range(cells(28,1) , cells(28,1).end(-4121)).select

instead of -4121 or -4161 you can use some excel constants like xldown xltoleft, etc but they'll only work with VBA of Excel (since they're excel constants)

Range("C5").Select - This should be selecting the next empty cell in column "C"
No, this will select cell C5
to select the next empty cell in column C you should use END(-4121) and then move one down.

Cells.Find(What:=" Thompson John L", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate - This should be what just was pasted in the last "C" column cell.
no, here you're searching " Thompson John L" and will select the cell where it finds that text.
to paste use PasteSpecial -4163 (this will paste only the values)

e.g.
to copy the range A5 to its down end and paste it in C5 just do:

Range(cells(5,1), cells(5,1).end(-4121)).copy
cells(5,3).pastespecial -4163

HTH
Sep 19 '07 #2
What I am trying to do is this:

I have a list that has the name address city etc in one column as such.

Name
address
city
other info

Name
address
city
other info

Name
address
city
other info

I want to get this information into this format.

name address city other info
name address city other info
name address city other info


As I said before, I don't know VBA, that's why I tried the record macro feature. I tried substituting the code you suggested, however I am missing something because i'm getting compilation errors. I also don't know how to move one cell down.
Sep 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
11
by: Randell D. | last post by:
Folks, I have a table of addresses and a seperate table with contact names - All addresses tie to one or more names - I would like to keep track of the number of names 'belonging' to an address...
2
by: JJA | last post by:
Please advise on how to get the GROUP BY coded in an acceptable way: DECLARE @LO INT DECLARE @HI INT DECLARE @StartDate varchar(10) DECLARE @EndDate varchar(10) SELECT @StartDate =...
16
by: Josué Maldonado | last post by:
Hello list, The TCL trigger that uses NEW and OLD arrays failed after after I removed a unused column, now I got this error: pltcl: Cache lookup for attribute '........pg.dropped.24........'...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
2
by: Jean S. Barto | last post by:
Hello-- I'm new here, and with using MS Access. I have a list of addresses that's now in MS Word, and it would be easier for me and the person I'm going to give this address list to, to be able...
3
by: PeterZ | last post by:
Hi, In a running C# app with a datagrid control I select all rows in the dataGrid using CTRL-A, I then paste into some other app like notepad or Word but the column headings get left off. Is...
21
by: py_genetic | last post by:
Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the...
1
by: christianlott1 | last post by:
I want to provide users with an interface to create a custom merge (all in Access, not Word). User will put in a set of brackets ("<>") in a memo field and when they click the merge button it will...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.