Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-13-2016, 10:24 AM
mcronin mcronin is offline Want to copy all rows that contain a specific value in column B Windows 7 64bit Want to copy all rows that contain a specific value in column B Office 2016
Novice
Want to copy all rows that contain a specific value in column B
 
Join Date: May 2016
Posts: 4
mcronin is on a distinguished road
Default Want to copy all rows that contain a specific value in column B

Hi,

So I have an input file that I need to be split up into various other tabs, this input file comes into my sheet nicely with my macro and generally has a very specific format so I am able to just code it to take specific row numbers and paste them into the correct tabs. If the formatting changes on my input file at all it will not work though. In very simple terms I just want to even just select all rows with a specific value in my column B.

I have attached the simplest form of data that I can provide to be able to do this, I would just like to be able to select all rows where column B = Sugar or Cotton or whatever it may be, so that I can copy and paste it into other tabs.

A small worry I have with this is also is whether there would be spaces in between the data when it gets copied and pasted. I can't have any spaces when it gets pasted.



THANKS!
Attached Files
File Type: xls book.xls (28.5 KB, 12 views)
Reply With Quote
  #2  
Old 06-13-2016, 10:37 AM
KingoftheKassel KingoftheKassel is offline Want to copy all rows that contain a specific value in column B Windows 7 64bit Want to copy all rows that contain a specific value in column B Office 2010 64bit
Novice
 
Join Date: Jul 2015
Posts: 5
KingoftheKassel is on a distinguished road
Default

What you need is the "Find" method. Here's the link that has a great explanation. After you define whatever you're looking for set a variable equal to your search variable then add ".EntireRow.Select" or copy or whatever you want to do. Here's an example of something I did before using .find :

Sub Frank ()

Dim source As Range
Dim FFS as Range
Dim destRow as String

Set source = ActiveWorkbook.Worksheets("IMPORT").Range("A9:A100 00")

Set FFS = source.Find(what:=searchString, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns)
destRow = FFS.EntireRow.Cut

End Sub


This code won't do EXACTLY what you're looking for, it's just an example of what how I used '.Find' . The link below will help tons.

http://www.globaliconnect.com/excel/...=79&Itemid=475
Reply With Quote
  #3  
Old 06-13-2016, 11:32 AM
mcronin mcronin is offline Want to copy all rows that contain a specific value in column B Windows 7 64bit Want to copy all rows that contain a specific value in column B Office 2016
Novice
Want to copy all rows that contain a specific value in column B
 
Join Date: May 2016
Posts: 4
mcronin is on a distinguished road
Default

Thanks KingoftheKassel but I have actually just found a little bit of an easier way to do this using autofiltering
Reply With Quote
  #4  
Old 06-15-2016, 09:44 AM
KunleExcel KunleExcel is offline Want to copy all rows that contain a specific value in column B Windows 8 Want to copy all rows that contain a specific value in column B Office 2010 32bit
Novice
 
Join Date: Jun 2016
Location: Nigeria
Posts: 17
KunleExcel is on a distinguished road
Default Copy List

Sub CopyList()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Sheet1.Activate

Dim ListRange As Range
Set ListRange = Range("B3", Range("B3").End(xlDown))

ListRange.Cells(1, 1).Select

Dim i As Long

Do While ActiveCell <> ""
i = WorksheetFunction.CountIf(ListRange, ActiveCell.Value)
Range(ActiveCell, ActiveCell.Offset(i - 1, -1)).Copy
ActiveCell.Offset(i, 0).Select

Sheets.Add after:=Sheets(Worksheets.Count)
ActiveCell.PasteSpecial
On Error Resume Next
ActiveSheet.Name = Cells(1, 2).Value
Selection.EntireColumn.AutoFit

Sheet1.Activate
Loop

Range("A1").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Attached Files
File Type: xlsm CopyList.xlsm (19.7 KB, 7 views)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
If column B cell is a certain value then copy and paste the value to column A Snaybot Excel Programming 1 12-01-2015 07:10 PM
Copy column 1 data into Column 3 ShailShin Word VBA 1 06-18-2015 10:49 AM
Excel copy two numbers between specific column and paste in next sheet visha_1984 Excel 1 12-26-2014 07:59 PM
how can i split a column of rows in half without copy and paste.. Lindseyfparker Excel 2 04-25-2014 12:52 AM
Want to copy all rows that contain a specific value in column B Find specific rows then copy and paste to new doc konopca Word VBA 5 02-20-2014 02:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:20 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft