Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display a report in excel 1

Status
Not open for further replies.

aharris2693

Programmer
Jul 15, 2003
45
US
I have built a form that asks the user for search criteria, and then which field to look under. After searching a sheet called "Projects", I want to display each record in a seperate sheet called "Report". My code is below.

Do Until (i > r)
If Range("Projects!A" & i & "") = Int(txtSearch) Then
Range("Report!A" & b & ":E" & b & "") =Range ("Projects!A" & i & ":E" & i & "")
b = b + 1
End If
i = i + 1
Loop

r is my last used row.
i is the last row searched
b is the last row filled in "Report"

I know that my search is working because I can display all of my information in a msgBox, but it will not display in the seperate sheet.

 
Hi aharris2693,

You can't assign Ranges like that. If you want to copy the data use something like ..

Code:
Range("Projects!A" & i & ":E" & i & "").Copy Range("Report!A" & b & ":E" & b & "")

Enjoy,
Tony
 
Thank you so much. Since Access is not standard software here, I am trying slowly to teach myself how to write VBA to make excel work accordingly. Thanks again for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top