Help! Need to copy only some columns in rows that have X condtn
Solved/Closed
TallPoppy
Posts
3
Registration date
Friday June 10, 2016
Status
Member
Last seen
June 11, 2016
-
Jun 10, 2016 at 04:28 AM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jun 11, 2016 at 06:34 AM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jun 11, 2016 at 06:34 AM
Related:
- Help! Need to copy only some columns in rows that have X condtn
- Display two columns in data validation list but return only one - Guide
- How to delete rows and columns in word - Guide
- Tweetdeck larger columns - Guide
- Which function is used to compare a cell value to an array of cells and return a value that matches the location of the value in the array, and is used when there are more than two columns in the array ✓ - Excel Forum
- Excel insert multiple rows - Guide
3 responses
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jun 10, 2016 at 08:21 AM
Jun 10, 2016 at 08:21 AM
Hello Sarah,
I'm not sure if I follow fully, but the following code may work for you:-
Following is the link to my test work book:-
https://www.dropbox.com/s/7cldr8jz6o0sx3f/TallPoppy%28Transfer%20data%2C%202%20criteria%2C%20autofilter%29.xlsm?dl=0
Click on the "RUN" button to see it work.
The code checks Column B for the criteria ("Phone Call" or "Digital Interaction") in the Active Sheet (your main sheet) and on finding the criteria, copies the relevant data from the columns that you specified to sheet2.
Please note that the test work book is an Excel file and may not work in Google Sheets as Google Sheets do not support macros. You can convert Google Sheets to an Excel file.
I do not have any experience with Google Sheets but I hope that this points you in the right direction at least.
Cheerio,
vcoolio.
I'm not sure if I follow fully, but the following code may work for you:-
Sub TransferData() Dim lr As Long Application.ScreenUpdating = False ActiveSheet.Columns("A").EntireColumn.Hidden = True ActiveSheet.Columns("F:I").EntireColumn.Hidden = True ActiveSheet.Columns("M:Z").EntireColumn.Hidden = True lr = Range("A" & Rows.Count).End(xlUp).Row Sheet2.UsedRange.Offset(1).ClearContents With ActiveSheet .AutoFilterMode = False With Range("B1", Range("B" & Rows.Count).End(xlUp)) .AutoFilter 1, "Phone Call", xlOr, "Digital Interaction" On Error Resume Next Range("B2:AB" & lr).Copy Sheet2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlPasteValues End With .AutoFilterMode = False End With ActiveSheet.Columns("A").EntireColumn.Hidden = False ActiveSheet.Columns("F:I").EntireColumn.Hidden = False ActiveSheet.Columns("M:Z").EntireColumn.Hidden = False Sheet2.Columns.AutoFit Application.CutCopyMode = False Application.ScreenUpdating = True MsgBox "Data transfer completed.", vbExclamation, "STATUS" End Sub
Following is the link to my test work book:-
https://www.dropbox.com/s/7cldr8jz6o0sx3f/TallPoppy%28Transfer%20data%2C%202%20criteria%2C%20autofilter%29.xlsm?dl=0
Click on the "RUN" button to see it work.
The code checks Column B for the criteria ("Phone Call" or "Digital Interaction") in the Active Sheet (your main sheet) and on finding the criteria, copies the relevant data from the columns that you specified to sheet2.
Please note that the test work book is an Excel file and may not work in Google Sheets as Google Sheets do not support macros. You can convert Google Sheets to an Excel file.
I do not have any experience with Google Sheets but I hope that this points you in the right direction at least.
Cheerio,
vcoolio.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jun 10, 2016 at 11:35 PM
Jun 10, 2016 at 11:35 PM
Hello Sarah,
A simple IF statement should work in Google Sheets. The following formulae are based on the sample work book in my first post. Play with the formulae in the test work book to see if its what you are after. Just don't click on the button!
In Sheet 2, starting in row 2, place the following formulae:-
Column A:-
=IF(Sheet1!$B2<>"",Sheet1!B2,"")
then drag it down as far as needed.
Column B:-
=IF(Sheet1!$B2<>"",Sheet1!C2,"")
dragged down again.
Column C:-
=IF(Sheet1!$B2<>"",Sheet1!D2,"")
dragged down.
Column D:-
=IF(Sheet1!$B2<>"",Sheet1!E2,"")
dragged down.
Column E:_
=IF(Sheet1!$B2<>"",Sheet1!J2,"")
dragged down
Column F:-
=IF(Sheet1!$B2<>"",Sheet1!K2,"")
dragged down
Column G:-
=IF(Sheet1!$B2<>"",Sheet1!L2,"")
dragged down.
Column H:-
=IF(Sheet1!$B2<>"",Sheet1!AA2,"")
dragged down.
Column I:-
=IF(Sheet1!$B2<>"",Sheet1!AB2,"")
dragged down.
The formulae above will bring across to sheet 2 only the data from the columns that you specified in your original post.
Using formulae, you will have blank rows in sheet2 if there isn't a value in the criteria column (Column B, sheet1). Do you wish to have a temporary value in the blank rows (such as N/A) until such time as a criteria is placed in the relevant cell in Column B, sheet1?
You should get the drift of what the formulae are doing, so you should be able to change things around to suit your actual work book.
Let us know what you think.
Cheerio,
vcoolio.
A simple IF statement should work in Google Sheets. The following formulae are based on the sample work book in my first post. Play with the formulae in the test work book to see if its what you are after. Just don't click on the button!
In Sheet 2, starting in row 2, place the following formulae:-
Column A:-
=IF(Sheet1!$B2<>"",Sheet1!B2,"")
then drag it down as far as needed.
Column B:-
=IF(Sheet1!$B2<>"",Sheet1!C2,"")
dragged down again.
Column C:-
=IF(Sheet1!$B2<>"",Sheet1!D2,"")
dragged down.
Column D:-
=IF(Sheet1!$B2<>"",Sheet1!E2,"")
dragged down.
Column E:_
=IF(Sheet1!$B2<>"",Sheet1!J2,"")
dragged down
Column F:-
=IF(Sheet1!$B2<>"",Sheet1!K2,"")
dragged down
Column G:-
=IF(Sheet1!$B2<>"",Sheet1!L2,"")
dragged down.
Column H:-
=IF(Sheet1!$B2<>"",Sheet1!AA2,"")
dragged down.
Column I:-
=IF(Sheet1!$B2<>"",Sheet1!AB2,"")
dragged down.
The formulae above will bring across to sheet 2 only the data from the columns that you specified in your original post.
Using formulae, you will have blank rows in sheet2 if there isn't a value in the criteria column (Column B, sheet1). Do you wish to have a temporary value in the blank rows (such as N/A) until such time as a criteria is placed in the relevant cell in Column B, sheet1?
You should get the drift of what the formulae are doing, so you should be able to change things around to suit your actual work book.
Let us know what you think.
Cheerio,
vcoolio.
TallPoppy
Posts
3
Registration date
Friday June 10, 2016
Status
Member
Last seen
June 11, 2016
Jun 11, 2016 at 06:04 AM
Jun 11, 2016 at 06:04 AM
Excellent thank you! I will definitely use this IF formula. It does exactly what I need (apart from not including the blank results in the row)....but I can live with this. I am really grateful to you, thank you very much for all of your help!
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jun 11, 2016 at 06:34 AM
Jun 11, 2016 at 06:34 AM
Hello Sarah,
You're welcome. Glad that I could help.
Good luck!
Cheerio,
vcoolio.
You're welcome. Glad that I could help.
Good luck!
Cheerio,
vcoolio.
Jun 10, 2016 at 03:49 PM