Writing a macro
Solved/Closed
Anna
-
May 14, 2010 at 07:51 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - May 26, 2010 at 12:24 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - May 26, 2010 at 12:24 PM
Related:
- Writing a macro
- How to write @ in a laptop - Guide
- Structure should be followed while writing the body of an email - Guide
- Spell number in excel without macro - Guide
- Macro excel download - Download - Spreadsheets
- Excel macro to create new sheet based on value in cells - Guide
4 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
May 14, 2010 at 08:14 AM
May 14, 2010 at 08:14 AM
You question does not have too much detail to give you a good answer. How ever, you can get a good idea of macro if you use the macro recorder of excel. Start the macro, then do what you want to do and stop the macro.This would give you a starting template.
Here is the link to direct you to my sample workbook.
https://authentification.site/files/22476709/SAMPLE.xls
Many thank
Anna.
https://authentification.site/files/22476709/SAMPLE.xls
Many thank
Anna.
sorry, please try this link
https://authentification.site/files/22617731/SAMPLE.xls
https://authentification.site/files/22617731/SAMPLE.xls
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
May 25, 2010 at 04:29 PM
May 25, 2010 at 04:29 PM
You would need to explain more based on sample file. Still I am not able to connect what you want and how sheets are related
Project tracker contains the a summary of the data, in order for me to expand on the contracts data i want to continue with this on sheet two. Hence if i had a macro which would automactically copy the data from cell A to I within the project tracker to the contracts worksheet provided there is a Y in the contracts column, this will provide the basic for me to continue. I undrestand at the moment some of the cells in column M, worksheet 1 contain a Y and some other data, i believe this would have to be consistant. I hope this helps
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
May 26, 2010 at 05:21 AM
May 26, 2010 at 05:21 AM
you can try below. This is based on assumption that
a. if the Project Number does not exist on Sheet Contract, the data is to be copied on the row below the last used cell in column A.
b. if the Project Number does exist on Sheet Contract, the data is to be copied over the existing data.
1. Press ALT + F11 to start VBE
2. Press CTRL + R to show Project Explorer
3. Double Click on the Sheet Project Tracker
4. Paste this code
a. if the Project Number does not exist on Sheet Contract, the data is to be copied on the row below the last used cell in column A.
b. if the Project Number does exist on Sheet Contract, the data is to be copied over the existing data.
1. Press ALT + F11 to start VBE
2. Press CTRL + R to show Project Explorer
3. Double Click on the Sheet Project Tracker
4. Paste this code
Private Sub Worksheet_Change(ByVal Target As Range) Dim lAtRow As Long Dim lThisRow As Long Dim Cell As Object Application.EnableEvents = False On Error GoTo Error_Handle For Each Cell In Target lThisRow = Cell.Row If ((lThisRow > 10) And (Cell.Column = 13) And (UCase(Cell) = "Y")) Then lAtRow = 0 On Error Resume Next lAtRow = Application.WorksheetFunction.Match(Cells(lThisRow, "A"), Sheets("Contracts").Range("A:A"), 0) On Error GoTo Error_Handle If lAtRow < 1 Then lAtRow = Sheets("Contracts").Cells(Rows.Count, "A").End(xlUp).Row + 1 Sheets("Contracts").Range("A" & lAtRow & ":I" & lAtRow) = Range("A" & lThisRow & ":I" & lThisRow).Value End If Next Cell END_SUB: Application.EnableEvents = True Exit Sub Error_Handle: MsgBox Err.Description GoTo END_SUB End Sub
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
May 26, 2010 at 06:09 AM
May 26, 2010 at 06:09 AM
It works in the sample sheet you provided. Could you post the file with the macro on the shared site with the macro
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
May 26, 2010 at 06:36 AM
May 26, 2010 at 06:36 AM
It works. You have some lines from line 63 and down
Read the assumptions and specially assumption "A"
Read the assumptions and specially assumption "A"
May 14, 2010 at 10:09 AM
May 14, 2010 at 05:33 PM
IF that is the case, what about this other sheet. Will it always exist, should the existing data on the sheet be wiped out or this new data be appended
Could you please upload a sample file with sample data etc on some shared site like https://authentification.site , http://wikisend.com/ , http://www.editgrid.com etc and post back here the link to allow better understanding of how it is now and how you foresee.