ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select column, cut and paste it to new worksheet (https://www.excelbanter.com/excel-programming/433346-select-column-cut-paste-new-worksheet.html)

Withnails

select column, cut and paste it to new worksheet
 
Hello

I am looking to select a column by a text word at the top of the column. I
would like the macro to find the word, select it and the data below it (until
the cells are blank) and copy this column into another column on worksheet2
of the same workbook.
The data in worksheet1 is roughly 15 columns by 20 rows (can vary), the cell
text will be items such as; End Bal. ledger, End Price, Client Name etc

I am unsure of how to find the text words and select a column in a row. The
position of the text along the row will change each time. Does anyone know
how this can be done? Thank you in advance for any info..


Jacob Skaria

select column, cut and paste it to new worksheet
 
Your below descriptions contradict each other. However try the below macro

select a column by a text word at the ** top ** of the column.
The position of the text along the row ** will change ** each time.


Sub Macro()

Dim varFound As Variant, strSearch As String
strSearch = "texttofind"

Set varFound = Sheets("Sheet1").Cells.Find(strSearch)
If Not varFound Is Nothing Then
Columns(varFound.Column).Copy Sheets("Sheet2").Range("A1")
Columns(varFound.Column).ClearContents
End If

End Sub
If this post helps click Yes
---------------
Jacob Skaria


"Withnails" wrote:

Hello

I am looking to select a column by a text word at the top of the column. I
would like the macro to find the word, select it and the data below it (until
the cells are blank) and copy this column into another column on worksheet2
of the same workbook.
The data in worksheet1 is roughly 15 columns by 20 rows (can vary), the cell
text will be items such as; End Bal. ledger, End Price, Client Name etc

I am unsure of how to find the text words and select a column in a row. The
position of the text along the row will change each time. Does anyone know
how this can be done? Thank you in advance for any info..



All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com