S
srsev6
Currently I am using a vba code to pull the data from one sheet in a workbook to another sheet based on the name I type in the input box. Unfortunately, this will only work for copying the data to one sheet. For instance, when I want to change the name and pull the data based on that name it will be added to the same sheet as the previous information.
This leaves me with two questions:
1. How can I pull data for each name and have the data copy to a differentsheet for each name? (For instance, if I enter "Bob" in the InputBox, I want the information for "Bob" to copy the sheet labeled "Bob". Then, I want to enter the name "Tina" and have Tina's information copied to the sheet labeled "Tina" and so on).
2. How can I link the InputBox below to a command button so others can quickly access the inputbox to enter the name.
If you need my spreadsheet to view the code please let me know.
Sub CopyData()
Application.ScreenUpdating = False
Dim name As String
name = InputBox("Please enter name to search.")
Dim bottomD As Integer
bottomD = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row
Dim c As Range
For Each c In Sheets("Sheet1").Range("D2" & bottomD)
If c = name And c.Offset(0, 1) <= Date And c.Offset(0, 3) = "" Then
Range(Cells(c.Row, 1), Cells(c.Row, 5)).Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End If
Next c
Application.ScreenUpdating = True
End Sub
Thank you so much for your time. It is greatly appreciated.
This leaves me with two questions:
1. How can I pull data for each name and have the data copy to a differentsheet for each name? (For instance, if I enter "Bob" in the InputBox, I want the information for "Bob" to copy the sheet labeled "Bob". Then, I want to enter the name "Tina" and have Tina's information copied to the sheet labeled "Tina" and so on).
2. How can I link the InputBox below to a command button so others can quickly access the inputbox to enter the name.
If you need my spreadsheet to view the code please let me know.
Sub CopyData()
Application.ScreenUpdating = False
Dim name As String
name = InputBox("Please enter name to search.")
Dim bottomD As Integer
bottomD = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row
Dim c As Range
For Each c In Sheets("Sheet1").Range("D2" & bottomD)
If c = name And c.Offset(0, 1) <= Date And c.Offset(0, 3) = "" Then
Range(Cells(c.Row, 1), Cells(c.Row, 5)).Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End If
Next c
Application.ScreenUpdating = True
End Sub
Thank you so much for your time. It is greatly appreciated.