hi,
I have been searching for a solution for some time now and hope that someone can help me!
i have a workbook that contains a number of sheets. sheet1 is titled "From" and is my data entry sheet. the other sheets are named with a contract number and an abbreviation of the contract type. ie: 0001-ABC, 0002-DEF etc.
I need a VBA code that can copy data (found at C8:CT9) from my data entry sheet and copy and paste special values only (to C60:CT61) any one of the other sheets based on what is stated in B1 of the data entry sheet. The person entring the data would choose from a driop down list the specific contract and enter the data into the data entry sheet. they would press a button and the data is transferred to the appropriate sheet.
i have found the code below:
Private Sub CommandButton1_Click()
Product$ = Right(Range("b1"), 5)
Range("C8:CT9").Copy
Dim WS_Count As Integer
Dim I As Integer
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 1 To WS_Count
' The following line shows how to reference a sheet within
' the loop using a simple text function
If Right$(ActiveWorkbook.Worksheets(I).Name, 5) = Product$ Then
Worksheets(I).Activate
End If
'Paste the data (values) in worksheet
ActiveSheet.Paste Destination:=Worksheets(I).Range("C60")
Next I
Application.CutCopyMode = False
End Sub
The problem with this code is the fact that it copies to all of the sheets but it will activate the sheet that is indicated in B1 and will take you uto that sheet. i need it to only paste to the specific sheet. Also, i need the code to paste special, values.
i hope someone can help me!
I have been searching for a solution for some time now and hope that someone can help me!
i have a workbook that contains a number of sheets. sheet1 is titled "From" and is my data entry sheet. the other sheets are named with a contract number and an abbreviation of the contract type. ie: 0001-ABC, 0002-DEF etc.
I need a VBA code that can copy data (found at C8:CT9) from my data entry sheet and copy and paste special values only (to C60:CT61) any one of the other sheets based on what is stated in B1 of the data entry sheet. The person entring the data would choose from a driop down list the specific contract and enter the data into the data entry sheet. they would press a button and the data is transferred to the appropriate sheet.
i have found the code below:
Private Sub CommandButton1_Click()
Product$ = Right(Range("b1"), 5)
Range("C8:CT9").Copy
Dim WS_Count As Integer
Dim I As Integer
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 1 To WS_Count
' The following line shows how to reference a sheet within
' the loop using a simple text function
If Right$(ActiveWorkbook.Worksheets(I).Name, 5) = Product$ Then
Worksheets(I).Activate
End If
'Paste the data (values) in worksheet
ActiveSheet.Paste Destination:=Worksheets(I).Range("C60")
Next I
Application.CutCopyMode = False
End Sub
The problem with this code is the fact that it copies to all of the sheets but it will activate the sheet that is indicated in B1 and will take you uto that sheet. i need it to only paste to the specific sheet. Also, i need the code to paste special, values.
i hope someone can help me!