VBA for daily Trakker

Mumgirl

New Member
Joined
Jan 7, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi All,



Wish you all, Happy new year, Hope you are doing good !!!

I am new on MrExcel Forum, looking for VBA for few tasks

First Task – One-time activity

I am preparing the workforce daily tracking sheet for all our partners, we will send this file by mail to the partners.

Once they open this file, they will fill details in Starting B1 to B4, there is one filed “Pin to Transfer Data” A5, here they will put their desired pin – will explain this bit letter

Starting B7 to B26 they will write Technician Name, I want to have a macro to create (Add) sheets based on a list provided in B7:B26.

I want to prevent macro in duplicating sheet however user can add technician name to list and macro should be able to create sheet based on newly added name in range B7:B26

Once a sheet is created, I want to copy mater data format from a sheet called hidden – this data should come with formatting and all data validations

In home tab apart from A1:E30 Rest cells should be protected with Password ( Password=1234)

Daily Monitoring Format.xlsb
ABCDE
1RegionNorth
2BranchCalcutta
3ASC NameKaka Electronics
4GCS CodeG2345562
5Pin to Transfer Data
6T#Name
7T1
8T2
9T3
10T4
11T5
12T6
13T7
14T8
15T9
16T10
17T11
18T12
19T13
20T14
21T15
22T16
23T17
24T18
25T19
26T20
27
28
29
Home
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B6:B26Cell ValueduplicatestextNO
Cells with Data Validation
CellAllowCriteria
B1ListEast,North,South,West
B2ListAhmedabad,Bangalore,Bhubaneswar,Calcutta,Chandigarh,Chennai,Delhi,Ghaziabad,Guwahati,Hyderabad,Indore,Jaipur,Kochi,Lucknow,Mumbai,Pune


Second Task
Once Technician sheets are created, the user will fill the required details in each technician list on daily basis.

I want to have a macro button on each sheet by clicking this button macro to ask to enter “Pin to Transfer Data” using input box and match input data with cell B5 in Home tab, this is just to prevent accidental transfer of data

If the input value is matching with B5 copy date dynamically ( sheet may have less data – macro to check data Cell B2 to last filled row and copy ) and paste it in “ASC Summary” sheet in column E Date, if not matching show massage, “Please enter correct code”,

Macro to append data on each transfer.

The region, Branch, GCS code, Technician Name data is not available in Technician sheet, macro to take input of Region, Branch, GCS code from Home tab and technician name from sheet name from where data was transferred. Macro to match Row with data copied from sheet to avoid any mismatch.



I don’t know how difficult this activity but am looking forward for support from experts.

Thanks
MumGirl
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
OK, I have made up some code to do your second task.
Please double check all the ranges and make sure they line up

VBA Code:
Sub addSheets()

For Each cell In ThisWorkbook.Sheets("Home").Range("B7:B26").Cells
    If cell <> "" Then 'if not at the end of the tech list then
        If DuplicateSheet(cell.Value) = False Then 'if tech name not a duplicate
            ThisWorkbook.Worksheets.Add 'Add a sheet
            ActiveSheet.Name = cell.Value 'Name sheet tech name
            ThisWorkbook.Sheets("Hidden").Cells.Copy ActiveSheet.Cells 'copy template from hiddel sheet to new sheet
            CreateButton ThisWorkbook.Sheets(cell.Value) 'create button on new sheet
        End If
    End If
Next cell

End Sub

Function DuplicateSheet(SheetName As String) As Boolean
    DuplicateSheet = False
    For Each sheet In ThisWorkbook.Sheets 'go through each sheet and make sure name doesn't already exist
        If sheet.Name = SheetName Then
            DuplicateSheet = True 'if duplicate then ignore sheet creation
            Exit For
        End If
    Next sheet
End Function

Function CreateButton(sht As Worksheet)
sht.Buttons.Add(199.5, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
With sht.Buttons("New Button")
    .Text = "Transfer Data" ' Text on the button
    .OnAction = "Transfer" ' sub called when button pressed
End With
End Function


Sub Transfer()
    'check pin with input
    Answer = InputBox("Please type the transfer pin from the home sheet here to continue", "Transfer the data now?")
    If Answer <> "" Then
        If Answer = ThisWorkbook.Sheets("Home").Range("B5") & "" Then
            'Passed all the tests
            If ThisWorkbook.Sheets("ASC Summary").Range("A2").Offset(1) = "" Then
                LastRow = ThisWorkbook.Sheets("ASC Summary").Range("A2").Offset(1).row
            Else
                LastRow = ThisWorkbook.Sheets("ASC Summary").Range("A2").End(xlDown).row + 1
            End If
            'Transfer data
            With ActiveSheet
                'add sheet data
                .Range("A2", "Q" & .Range("A1").End(xlDown).row).Copy ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 5)
                'add home data
                With ThisWorkbook.Sheets("Home")
                    .Range("B1:B2").Copy
                    ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 1).PasteSpecial Transpose:=True
                    ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 3) = .Range("B4")
                End With
                ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 4) = .Name
                'Delete Sheet
                Application.DisplayAlerts = False 'turn off message to delete sheet
                .Delete
                Application.DisplayAlerts = True
            End With

        Else
            MsgBox "You have not entered the correct pin" & vbNewLine & "Please try again", vbCritical + vbOKOnly, "Something went wrong"
        End If
    End If
End Sub
 
Upvote 0
OK, I have made up some code to do your second task.
Please double check all the ranges and make sure they line up

VBA Code:
Sub addSheets()

For Each cell In ThisWorkbook.Sheets("Home").Range("B7:B26").Cells
    If cell <> "" Then 'if not at the end of the tech list then
        If DuplicateSheet(cell.Value) = False Then 'if tech name not a duplicate
            ThisWorkbook.Worksheets.Add 'Add a sheet
            ActiveSheet.Name = cell.Value 'Name sheet tech name
            ThisWorkbook.Sheets("Hidden").Cells.Copy ActiveSheet.Cells 'copy template from hiddel sheet to new sheet
            CreateButton ThisWorkbook.Sheets(cell.Value) 'create button on new sheet
        End If
    End If
Next cell

End Sub

Function DuplicateSheet(SheetName As String) As Boolean
    DuplicateSheet = False
    For Each sheet In ThisWorkbook.Sheets 'go through each sheet and make sure name doesn't already exist
        If sheet.Name = SheetName Then
            DuplicateSheet = True 'if duplicate then ignore sheet creation
            Exit For
        End If
    Next sheet
End Function

Function CreateButton(sht As Worksheet)
sht.Buttons.Add(199.5, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
With sht.Buttons("New Button")
    .Text = "Transfer Data" ' Text on the button
    .OnAction = "Transfer" ' sub called when button pressed
End With
End Function


Sub Transfer()
    'check pin with input
    Answer = InputBox("Please type the transfer pin from the home sheet here to continue", "Transfer the data now?")
    If Answer <> "" Then
        If Answer = ThisWorkbook.Sheets("Home").Range("B5") & "" Then
            'Passed all the tests
            If ThisWorkbook.Sheets("ASC Summary").Range("A2").Offset(1) = "" Then
                LastRow = ThisWorkbook.Sheets("ASC Summary").Range("A2").Offset(1).row
            Else
                LastRow = ThisWorkbook.Sheets("ASC Summary").Range("A2").End(xlDown).row + 1
            End If
            'Transfer data
            With ActiveSheet
                'add sheet data
                .Range("A2", "Q" & .Range("A1").End(xlDown).row).Copy ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 5)
                'add home data
                With ThisWorkbook.Sheets("Home")
                    .Range("B1:B2").Copy
                    ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 1).PasteSpecial Transpose:=True
                    ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 3) = .Range("B4")
                End With
                ThisWorkbook.Sheets("ASC Summary").Cells(LastRow, 4) = .Name
                'Delete Sheet
                Application.DisplayAlerts = False 'turn off message to delete sheet
                .Delete
                Application.DisplayAlerts = True
            End With

        Else
            MsgBox "You have not entered the correct pin" & vbNewLine & "Please try again", vbCritical + vbOKOnly, "Something went wrong"
        End If
    End If
End Sub
Hi EFANYoutube,


Thanks a lot for all your efforts !!!

The code is working partially fine.

Only a few observations

1> Once run "addSheets" macro - Sheets are getting created however Data transfer button in coming in between the data ( in cell D1) please let me know how we can shift it to cell W2 for all sheets which will get created
2> On clicking transfer data following actions are happening
  1. Complete Sheet ( Newly created Technician sheet) is getting deleted – We want to transfer data and clear from technician sheet we don’t want to delete the sheet
  2. Data is getting copied from Technician sheet Cell A1 ( which is serial number Column ) – We want to copy from column B ( Date column) That too till the filled cell only.
  3. In some cases the first row is blank - nothing is getting pasted there
  4. In Sheet ASC summary Region Branch GCS code and technician name is getting filed in one row only whereas we wanted to paste these details in line with data copied from the technician list and pasted ASC summary list.
  5. Data transfer button which is created in technician sheet is also moving in ASC summary – we don’t want this button to get copied and pasted in ASC summary
  6. In ASC summary data is getting replaced on click of transfer button whereas we want to append ( wanted to paste new data from next line and keep on moving down)
Please guide me to update the code so that I can change the same accordingly

But overall, I must appreciate your efforts and make it happen.

Thanks a lot for all your support!!!

ASC Daily Monitoring Format - Copy.xlsm
ABCDEFGHIJKLMNOPQRSTUVW
1RegionBranchGCS CodeTechnician NameDateWork order NoW/o DateCustomer NameAreaModel NoSerial NumberDOPWarranty StatusPart CodePart QtyAppointment StatusAppointment TimeStatus of callType of callAmount CollectedHappy Call StatusHappy Call DateRemarks
2
3NorthCalcuttaG2345562Santosh107-01-2160-1444266288607-01-21Aniruth Abhinandana BhattacharyyaThiruvananthapuramHL1643/00HL099999999999907-01-21Stock Set########1Yes3:30 PMSolved₹ 750.00
4NorthCalcuttaG2345562Bhikaji107-01-21Test07-01-21Aniruth Abhinandana BhattacharyyaThiruvananthapuramHL1643/00HL099999999999907-01-21Stock Set########1Yes3:30 PMSolved₹ 750.00
5207-01-21Test07-01-21ThiruvananthapuramHL1643/00HL099999999999907-01-21EWNot Attended
63
74
85
96
107
118
129
1310
1411
1512
1613
1714
ASC Summary
Cells with Data Validation
CellAllowCriteria
N3:N17ListIW,OW,Stock Set,EW
Q3:Q17ListYes,No
S3:S23ListSolved,Pending,Not Attended
T3:T23ListPR,NPR,Exchange,Demo
A3:A5ListEast,North,South,West
B3:B5ListAhmedabad,Bangalore,Bhubaneswar,Calcutta,Chandigarh,Chennai,Delhi,Ghaziabad,Guwahati,Hyderabad,Indore,Jaipur,Kochi,Lucknow,Mumbai,Pune



Thanks & Regards
 
Upvote 0
OK, no problems
I have changed the below too 1000, its how far right it will go, just tweek it till its good
VBA Code:
sht.Buttons.Add(1000, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
This line with clear the sheet instead of deleting
VBA Code:
.Range("A2:Q100").ClearContents
Changed it to copy from B Column (Date)

In you previous picture your headers were in 2nd row, I have fixed so no empty row now

The reason the button was getting coppied was because it was on top of the data being copied, this should be fixed now with moving the button away from the data

Should be appending now

The updated code below. Just overwrite the code already in your module

VBA Code:
Sub addSheets()

For Each cell In ThisWorkbook.Sheets("Home").Range("B7:B26").Cells
    If cell <> "" Then 'if not at the end of the tech list then
        If DuplicateSheet(cell.Value) = False Then 'if tech name not a duplicate
            ThisWorkbook.Worksheets.Add 'Add a sheet
            ActiveSheet.Name = cell.Value 'Name sheet tech name
            ThisWorkbook.Sheets("Hidden").Cells.Copy ActiveSheet.Cells 'copy template from hiddel sheet to new sheet
            CreateButton ThisWorkbook.Sheets(cell.Value) 'create button on new sheet
        End If
    End If
Next cell

End Sub

Function DuplicateSheet(SheetName As String) As Boolean
    DuplicateSheet = False
    For Each sheet In ThisWorkbook.Sheets 'go through each sheet and make sure name doesn't already exist
        If sheet.Name = SheetName Then
            DuplicateSheet = True 'if duplicate then ignore sheet creation
            Exit For
        End If
    Next sheet
End Function

Function CreateButton(sht As Worksheet)
sht.Buttons.Add(1000, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
With sht.Buttons("New Button")
    .Text = "Transfer Data" ' Text on the button
    .OnAction = "Transfer" ' sub called when button pressed
End With
End Function


Sub Transfer()
    'check pin with input
    Answer = InputBox("Please type the transfer pin from the home sheet here to continue", "Transfer the data now?")
    If Answer <> "" Then
        If Answer = ThisWorkbook.Sheets("Home").Range("B5") & "" Then
            'Passed all the tests
            If ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1) = "" Then
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1).row
            Else
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").End(xlDown).row + 1
            End If
            'Transfer data
            With ActiveSheet
                'add sheet data
                Dim RowCount As Integer
                RowCount = .Range("B1", "B" & .Range("B1").End(xlDown).row).Rows.Count - 1
                .Range("B2", "Q" & RowCount + 1).Copy ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 5)
                'add home data
                With ThisWorkbook.Sheets("Home")
                    .Range("B1:B2").Copy
                    ThisWorkbook.Sheets("ASC Summary").Range(Cells(lastrow, 1), Cells(lastrow + RowCount - 1, 1)).PasteSpecial Transpose:=True
                    ThisWorkbook.Sheets("ASC Summary").Range(Cells(lastrow, 3), Cells(lastrow + RowCount - 1, 3)) = .Range("B4")
                End With
                ThisWorkbook.Sheets("ASC Summary").Range(Cells(lastrow, 4), Cells(lastrow + RowCount - 1, 4)) = .Name
                'Clear Sheet
                .Range("A2:Q100").ClearContents
            End With

        Else
            MsgBox "You have not entered the correct pin" & vbNewLine & "Please try again", vbCritical + vbOKOnly, "Something went wrong"
        End If
    End If
End Sub
 
Upvote 0
OK, no problems
I have changed the below too 1000, its how far right it will go, just tweek it till its good
VBA Code:
sht.Buttons.Add(1000, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
This line with clear the sheet instead of deleting
VBA Code:
.Range("A2:Q100").ClearContents
Changed it to copy from B Column (Date)

In you previous picture your headers were in 2nd row, I have fixed so no empty row now

The reason the button was getting coppied was because it was on top of the data being copied, this should be fixed now with moving the button away from the data

Should be appending now

The updated code below. Just overwrite the code already in your module

VBA Code:
Sub addSheets()

For Each cell In ThisWorkbook.Sheets("Home").Range("B7:B26").Cells
    If cell <> "" Then 'if not at the end of the tech list then
        If DuplicateSheet(cell.Value) = False Then 'if tech name not a duplicate
            ThisWorkbook.Worksheets.Add 'Add a sheet
            ActiveSheet.Name = cell.Value 'Name sheet tech name
            ThisWorkbook.Sheets("Hidden").Cells.Copy ActiveSheet.Cells 'copy template from hiddel sheet to new sheet
            CreateButton ThisWorkbook.Sheets(cell.Value) 'create button on new sheet
        End If
    End If
Next cell

End Sub

Function DuplicateSheet(SheetName As String) As Boolean
    DuplicateSheet = False
    For Each sheet In ThisWorkbook.Sheets 'go through each sheet and make sure name doesn't already exist
        If sheet.Name = SheetName Then
            DuplicateSheet = True 'if duplicate then ignore sheet creation
            Exit For
        End If
    Next sheet
End Function

Function CreateButton(sht As Worksheet)
sht.Buttons.Add(1000, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
With sht.Buttons("New Button")
    .Text = "Transfer Data" ' Text on the button
    .OnAction = "Transfer" ' sub called when button pressed
End With
End Function


Sub Transfer()
    'check pin with input
    Answer = InputBox("Please type the transfer pin from the home sheet here to continue", "Transfer the data now?")
    If Answer <> "" Then
        If Answer = ThisWorkbook.Sheets("Home").Range("B5") & "" Then
            'Passed all the tests
            If ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1) = "" Then
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1).row
            Else
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").End(xlDown).row + 1
            End If
            'Transfer data
            With ActiveSheet
                'add sheet data
                Dim RowCount As Integer
                RowCount = .Range("B1", "B" & .Range("B1").End(xlDown).row).Rows.Count - 1
                .Range("B2", "Q" & RowCount + 1).Copy ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 5)
                'add home data
                With ThisWorkbook.Sheets("Home")
                    .Range("B1:B2").Copy
                    ThisWorkbook.Sheets("ASC Summary").Range(Cells(lastrow, 1), Cells(lastrow + RowCount - 1, 1)).PasteSpecial Transpose:=True
                    ThisWorkbook.Sheets("ASC Summary").Range(Cells(lastrow, 3), Cells(lastrow + RowCount - 1, 3)) = .Range("B4")
                End With
                ThisWorkbook.Sheets("ASC Summary").Range(Cells(lastrow, 4), Cells(lastrow + RowCount - 1, 4)) = .Name
                'Clear Sheet
                .Range("A2:Q100").ClearContents
            End With

        Else
            MsgBox "You have not entered the correct pin" & vbNewLine & "Please try again", vbCritical + vbOKOnly, "Something went wrong"
        End If
    End If
End Sub
Hi EFANYoutube,

I copied new code and overwrite on earlier code,

But new code is giving error sharing snap below, Please guide

Img.jpg
 
Upvote 0
Pretty sure i found the issue, there were 3 lines of code where i wasn't being explicit enough
VBA Code:
Sub addSheets()

For Each cell In ThisWorkbook.Sheets("Home").Range("B7:B26").Cells
    If cell <> "" Then 'if not at the end of the tech list then
        If DuplicateSheet(cell.Value) = False Then 'if tech name not a duplicate
            ThisWorkbook.Worksheets.Add 'Add a sheet
            ActiveSheet.Name = cell.Value 'Name sheet tech name
            ThisWorkbook.Sheets("Hidden").Cells.Copy ActiveSheet.Cells 'copy template from hiddel sheet to new sheet
            CreateButton ThisWorkbook.Sheets(cell.Value) 'create button on new sheet
        End If
    End If
Next cell

End Sub

Function DuplicateSheet(SheetName As String) As Boolean
    DuplicateSheet = False
    For Each sheet In ThisWorkbook.Sheets 'go through each sheet and make sure name doesn't already exist
        If sheet.Name = SheetName Then
            DuplicateSheet = True 'if duplicate then ignore sheet creation
            Exit For
        End If
    Next sheet
End Function

Function CreateButton(sht As Worksheet)
sht.Buttons.Add(1000, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
With sht.Buttons("New Button")
    .Text = "Transfer Data" ' Text on the button
    .OnAction = "Transfer" ' sub called when button pressed
End With
End Function


Sub Transfer()
    'check pin with input
    Answer = InputBox("Please type the transfer pin from the home sheet here to continue", "Transfer the data now?")
    If Answer <> "" Then
        If Answer = ThisWorkbook.Sheets("Home").Range("B5") & "" Then
            'Passed all the tests
            If ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1) = "" Then
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1).row
            Else
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").End(xlDown).row + 1
            End If
            'Transfer data
            With ActiveSheet
                'add sheet data
                Dim RowCount As Integer
                RowCount = .Range("B1", "B" & .Range("B1").End(xlDown).row).Rows.Count - 1
                .Range("B2", "Q" & RowCount + 1).Copy ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 5)
                'add home data
                With ThisWorkbook.Sheets("Home")
                    .Range("B1:B2").Copy
                    'Application.Wait (Now + TimeValue("00:00:01"))
                    ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 1), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 1)).PasteSpecial Transpose:=True
                    ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 3), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 3)) = .Range("B4")
                End With
                ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 4), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 4)) = .Name
                'Clear Sheet
                .Range("A2:Q100").ClearContents
            End With

        Else
            MsgBox "You have not entered the correct pin" & vbNewLine & "Please try again", vbCritical + vbOKOnly, "Something went wrong"
        End If
    End If
End Sub
 
Upvote 0
Pretty sure i found the issue, there were 3 lines of code where i wasn't being explicit enough
VBA Code:
Sub addSheets()

For Each cell In ThisWorkbook.Sheets("Home").Range("B7:B26").Cells
    If cell <> "" Then 'if not at the end of the tech list then
        If DuplicateSheet(cell.Value) = False Then 'if tech name not a duplicate
            ThisWorkbook.Worksheets.Add 'Add a sheet
            ActiveSheet.Name = cell.Value 'Name sheet tech name
            ThisWorkbook.Sheets("Hidden").Cells.Copy ActiveSheet.Cells 'copy template from hiddel sheet to new sheet
            CreateButton ThisWorkbook.Sheets(cell.Value) 'create button on new sheet
        End If
    End If
Next cell

End Sub

Function DuplicateSheet(SheetName As String) As Boolean
    DuplicateSheet = False
    For Each sheet In ThisWorkbook.Sheets 'go through each sheet and make sure name doesn't already exist
        If sheet.Name = SheetName Then
            DuplicateSheet = True 'if duplicate then ignore sheet creation
            Exit For
        End If
    Next sheet
End Function

Function CreateButton(sht As Worksheet)
sht.Buttons.Add(1000, 20, 81, 36).Name = "New Button" ' Change these values to move and resize the buttons
With sht.Buttons("New Button")
    .Text = "Transfer Data" ' Text on the button
    .OnAction = "Transfer" ' sub called when button pressed
End With
End Function


Sub Transfer()
    'check pin with input
    Answer = InputBox("Please type the transfer pin from the home sheet here to continue", "Transfer the data now?")
    If Answer <> "" Then
        If Answer = ThisWorkbook.Sheets("Home").Range("B5") & "" Then
            'Passed all the tests
            If ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1) = "" Then
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1).row
            Else
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").End(xlDown).row + 1
            End If
            'Transfer data
            With ActiveSheet
                'add sheet data
                Dim RowCount As Integer
                RowCount = .Range("B1", "B" & .Range("B1").End(xlDown).row).Rows.Count - 1
                .Range("B2", "Q" & RowCount + 1).Copy ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 5)
                'add home data
                With ThisWorkbook.Sheets("Home")
                    .Range("B1:B2").Copy
                    'Application.Wait (Now + TimeValue("00:00:01"))
                    ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 1), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 1)).PasteSpecial Transpose:=True
                    ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 3), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 3)) = .Range("B4")
                End With
                ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 4), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 4)) = .Name
                'Clear Sheet
                .Range("A2:Q100").ClearContents
            End With

        Else
            MsgBox "You have not entered the correct pin" & vbNewLine & "Please try again", vbCritical + vbOKOnly, "Something went wrong"
        End If
    End If
End Sub
Hi EFANYoutube,

Almost everything is fine only one last point, I have moved transfer button by increasing number to 1600 but still it is getting copied while transferring data to ASC summary.

Could you please share trick to avoid coping the same.

Thanks & Regards
 
Upvote 0
This is just the transfer code so make sure you only overwrite the transfer sub
I added this line twice, one to turn it off then to turn it on again after the copy
VBA Code:
                Application.CopyObjectsWithCells = False

So just copy the code below


VBA Code:
Sub Transfer()
    'check pin with input
    Answer = InputBox("Please type the transfer pin from the home sheet here to continue", "Transfer the data now?")
    If Answer <> "" Then
        If Answer = ThisWorkbook.Sheets("Home").Range("B5") & "" Then
            'Passed all the tests
            If ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1) = "" Then
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").Offset(1).row
            Else
                lastrow = ThisWorkbook.Sheets("ASC Summary").Range("A1").End(xlDown).row + 1
            End If
            'Transfer data
            With ActiveSheet
                'add sheet data
                Dim RowCount As Integer
                RowCount = .Range("B1", "B" & .Range("B1").End(xlDown).row).Rows.Count - 1
                Application.CopyObjectsWithCells = False
                .Range("B2", "Q" & RowCount + 1).Copy ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 5)
                Application.CopyObjectsWithCells = True
                'add home data
                With ThisWorkbook.Sheets("Home")
                    .Range("B1:B2").Copy
                    'Application.Wait (Now + TimeValue("00:00:01"))
                    ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 1), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 1)).PasteSpecial Transpose:=True
                    ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 3), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 3)) = .Range("B4")
                End With
                ThisWorkbook.Sheets("ASC Summary").Range(ThisWorkbook.Sheets("ASC Summary").Cells(lastrow, 4), ThisWorkbook.Sheets("ASC Summary").Cells(lastrow + RowCount - 1, 4)) = .Name
                'Clear Sheet
                .Range("A2:Q100").ClearContents
            End With

        Else
            MsgBox "You have not entered the correct pin" & vbNewLine & "Please try again", vbCritical + vbOKOnly, "Something went wrong"
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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