I need someone's help.

gadawgsr1

New Member
Joined
Nov 4, 2002
Messages
11
I have posted this message before and received one reply which was asking for more detail I have included that detail but I have yet to get an answer.

Can anyone help?

I need to figure out how to have Excel go to another sheet in a workbook and determine if a value exist and if it does exist, then copy everything in the row to the right of the value to a specified sheet in respective columns in the same workbook.

1. What do you mean "exists?" Test to see if a cell is empty? Yes

And perhaps that it contains a particular thing? Looking for the letter "B" or something like that.

2. What do you mean by "the row beside it?" Just the adjacent cells to the right and left? The remaining row to the right of it with information in it or just specific cells in that row.

Or perhaps the entire row? Not necessarily

3. Do you want just the cell contents copied or do you want to include all cell properties (color fill, font, borders, validations, comments, etc.)?
Yes everything.

Anyone have any ideas? Help.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Post a small sample of your data and specify:

1. What test needs to be performed to determine if the row is to be copied.

2. Whether the test needs to be performed more than once.

3. The name of the target sheet.
 
Upvote 0
On 2002-11-06 11:12, Andrew Poulsom wrote:
Post a small sample of your data and specify:

1. What test needs to be performed to determine if the row is to be copied.
I want it to go to sheet2 and look in column A find the letter "B" and copy some information from that row to the right of the that "B" and so on down the database. The database is a list of products that has certain description information identifying it. The whole point to this function is to list in summary what the customer is wanting purchase for a proposal of sorts.


2. Whether the test needs to be performed more than once. Yes the test will be performed about 2000 times from the sheet2.

3. The name of the target sheet.

email me if you think you can help me
tbrooks@aia-group.com
I know this will probably work better in Access but the friend of mine I'm helping has put a great deal of time in data entry into this workbook.
 
Upvote 0
This should get you started:

Code:
Sub Test()
    Dim Rng As Range
    Dim Sh As Worksheet
    Dim c As Range
    Dim x As Integer
    Set Rng = Worksheets("Sheet2").Range("A1:A" & Range("A65536").End(xlUp).Row)
    Set Sh = Worksheets.Add
    x = 1
    For Each c In Rng
        If c.Value = "B" Then
            c.EntireRow.Copy Sh.Cells(x, 1)
            x = x + 1
        End If
    Next c
End Sub

It copies the data to a new sheet.
 
Upvote 0
On 2002-11-06 11:35, Andrew Poulsom wrote:
This should get you started:

Code:
Sub Test()
    Dim Rng As Range
    Dim Sh As Worksheet
    Dim c As Range
    Dim x As Integer
    Set Rng = Worksheets("Sheet2").Range("A1:A" & Range("A65536").End(xlUp).Row)
    Set Sh = Worksheets.Add
    x = 1
    For Each c In Rng
        If c.Value = "B" Then
            c.EntireRow.Copy Sh.Cells(x, 1)
            x = x + 1
        End If
    Next c
End Sub

It copies the data to a new sheet.

Thank you so much Andrew!

This is so cool!
I have modified the code to return the information I need but it is setup to create a new sheet each time and I need it to be compiled in an existing sheet called "Estimate" starting with row number 2. I also need to know how to add additional sheet names for the code to check for the "B", i.e. "Flooring". The modified code is below but returns an error in it's existing form.

Sub Test()
Dim Rng As Range
Dim Sh As Worksheet
Dim c As Range
Dim x As Integer
Set Rng = Worksheets("Flooring").Range("A1:A" & Range("A65536").End(xlUp).Row)
Set Sh = Worksheets.Add("Estimate")
x = 1
For Each c In Rng
If c.Value = "B" Then
c.EntireRow.Copy Sh.Cells(x, 1)
x = x + 1
End If
Next c
End Sub

Thanks so much for your help.
Tim
 
Upvote 0
I think:

Code:
Sub Test() 
   Dim Rng As Range 
   Dim Sh As Worksheet 
   Dim c As Range 
   Dim x As Integer 
   Set Rng = Worksheets("Flooring").Range("A1:A" & Range("A65536").End(xlUp).Row) 
   Set Sh = Worksheets("Estimate") 
'  Delete existing data
   Sh.Range("A2:A" & Range("A65536").End(xlUp).Row).EntireRow.Clear 
   x = 2 
   For Each c In Rng 
      If c.Value = "B" Then 
         c.EntireRow.Copy Sh.Cells(x, 1) 
         x = x + 1 
      End If 
   Next c 
End Sub

What are the names of the additional sheets you need to search?
 
Upvote 0

Forum statistics

Threads
1,213,528
Messages
6,114,154
Members
448,553
Latest member
slaytonpa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top