Copy data from one sheet to other

aakhan2011

New Member
Joined
Jan 12, 2014
Messages
21
Data (i.e. 34864) in cell A110 of "Mod" sheet needs to be copied to Cell B9 of "Email Data" sheet.

Logic for copying is -
The VBA code will search for "COUNT(DISTINCTM.TRANS_ID)" keyword in "Mod" sheet and when found will move to next two row down and copy data(integer value 34864 / or any other value which is present) and paste in Cell B9 of "Email Data" sheet.

Sheet attached for your reference.

Worksheet.xlsm

Any help will be highly appreciated.

Button in "Email Data" sheet will do this function
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try:

Code:
Sub Test()
    Dim Cell As Range
    With Worksheets("Mod")
        Set Cell = .Cells.Find(What:="COUNT(DISTINCTM.TRANS_ID)", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlWhole)
        If Not Cell Is Nothing Then
            Worksheets("Email Data").Range("B9").Value = Cell.Offset(2).Value
        End If
    End With
End Sub
 
Upvote 0
Try:

Code:
Sub Test()
    Dim Cell As Range
    With Worksheets("Mod")
        Set Cell = .Cells.Find(What:="COUNT(DISTINCTM.TRANS_ID)", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlWhole)
        If Not Cell Is Nothing Then
            Worksheets("Email Data").Range("B9").Value = Cell.Offset(2).Value
        End If
    End With
End Sub

Works fine .

But When i use the same code for searching COUNT(*) , it doesn't does. May be (*) is causing the problem.

Can you please check, we have the COUNT(*) in cell A114 in "Mod" sheet as provided above.

PHP:
Sub Test2()
Dim Cell As Range
   With Worksheets("Mod")
        Set Cell = .Cells.Find(What:="COUNT(*)", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlWhole)
        If Not Cell Is Nothing Then
            Worksheets("Email Data").Range("D9").Value = Cell.Offset(2).Value
        End If
    End With

End Sub
 
Upvote 0
The asterisk is a wildcard so you need to escape it with a tilde:

Rich (BB code):
What:="COUNT(~*)"

Even the ~ symbol doesn't work. Can you please check in the sheet i have attached in my first post and sent the file or let me know.

Code:
Sub Test2()
 Dim Cell As Range
    With Worksheets("Mod")
        Set Cell = .Cells.Find(What:="COUNT(~*)", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlWhole)
        If Not Cell Is Nothing Then
            Worksheets("Email Data").Range("D9").Value = Cell.Offset(2).Value
        End If
    End With

End Sub

Waiting for the reply ..
 
Upvote 0
It does work, but the COUNT(*) in B2 is found first. Try:

Rich (BB code):
Set Cell = .Columns(1).Find(What:="COUNT(~*)", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlWhole)
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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