Below is just a macro I recorded myself which may or may not be helpful. Basically, I am trying to copy the number, name, and date from one sheet (Worksheet) then paste into a different spreasheet (Data Entry Form).
FYI, the number, name, and date goes from left to right on the ‘Worksheet’, and Each row of data (number, name , and date) needs to go into a separate ‘Data Entry Form’.
So I am looking for a macro that will use the data from “Worksheet” and place it into the ‘Data Entry Form’ while generating additional ‘Data Entry Forms’ (more worksheets) for each separate row of data.
The number of rows in the Worksheet can vary from 10-100 so having a macro would save me ample time of copying and pasting into new forms; even if the macro can only do one row of data at a time.
Sub Popsecform()
'
' Popsecform Macro
'
' Keyboard Shortcut: Ctrl+m
'
Selection.Copy
Windows("Data Entry form.xlsx").Activate
Range("F8").Select
ActiveSheet.Paste
Windows("Worksheet.xlsx").Activate
Range("C2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Entry form.xlsx").Activate
Range("F30").Select
ActiveSheet.Paste
Windows("Worksheet.xlsx").Activate
Range("D2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Entry form.xlsx").Activate
Range("F24").Select
ActiveSheet.Paste
End Sub
Edit
I am just trying to create a workbook that will be able to generate my Data Entry Form as an additional sheet to the workbook every time I add another row of Name, Number, and Date to the first Worksheet.
Row A goes to Data Entry Form 1 (Distinct cells)
Row B goes to Data Entry Form 2 (same distinct cells)
and so on
Related
I have been piecemealing code based on internet research.
I am attempting to add a row to the table (with a button).
I am looking to add the row between Rows 6 and 7 so the user could add location 4-1, 5-1 etc.
After the row is added I want the same formatting applied (all outlines) and the formulas in the non-highlighted columns to be carried over as well into the newly created row.
From my understanding the way I have the SUM formula at the bottom of the table it should automatically expand itself to account for the newly added rows.
If it assists with an example, the name of this table is "Prop_Exp".
The code I have will work on one instance, but within the same workbook I need to create other "add row" buttons for various classes of business. The references end up being shifted based on if any rows were added in the preceding sections.
All tables have a uniform number of columns and formulas so I feel its a matter of finding the bottommost row in the table based on finding the word total (or other metric) and then from that reference point adding a row based on offset and then copy/paste from there (again with offset).
What I have tried
My gut reaction was to include the information within various tabs so there would be only one "total" row. And I could Ctrl+Down Arrow to find the bottom, but then I realized that as data is added the Ctrl+Down will no longer function as intended as the command will find the bottom in any data entered and throw off the reference point.
Sub Add_Prop_Row()
'
' Add_Prop_Row Macro
'
'
Range("B1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.Offset(-3, 0).Select
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
Selection.End(xlDown).Select
Range(Cells(Selection.Row, 3), Cells(Selection.Row, 10)).Select
Selection.Copy
Range(ActiveCell.Offset(-2, 0), ActiveCell.Offset(-2, 0)).Select
Selection.PasteSpecial Paste:=xlPasteFormulasAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("C1").Select
End Sub
I searched for a way to reference the word "total" in a table. Thought process was once I could find the word "total" I could use offset from there, and if need be find a way to loop the command to keep finding it as a reference, but the match formula is giving me an error.
Sub Macro2()
'
' Macro2 Macro
'
ActiveSheet.ListObjects("Prop_Exp").Range.Select
.Formula = Match(Total, $A:$A,0)
'
End Sub
Firstly I have to apologise as this is my first attempt at any VBA coding!
I am trying to find a way of automating a process whereby I extract data from a single data sheet with multiple columns in it into several separate worksheets.
My source data sheet has multiple column headings that are identified by their heading name, column number and column reference.
I am looking for some code that will (for the 2 specified column headings in each of my output sheets:
perform an auto filter selection (=Blanks for column 1 in the operation, <> Blanks for column 2 in the operation)
copy and paste the returned data into a specified output sheet
reset the auto filters in data sheet
move onto the next output sheet, select the next two relevant columns identified in the next output sheet
perform an auto filter selection (=Blanks for column 1 in the operation, <> Blanks for column 2 in the operation)
copy and paste the returned data into a specified output sheet
reset the auto filters in data sheet etc.
I can do this for 1 sheet and repeat but fall over due to the data sheet columns not necessarily remaining in the same order (as new activity milestones are added between the activity I am counting are added).
My crude code is below:
Sub FcastSFR()
'
' FcastSFR Macro
'
'
Application.ScreenUpdating = False
Range("A23:B345").Select
Selection.ClearContents
Sheets("MOAT").Select
ActiveSheet.ShowAllData
ActiveSheet.Range("$A$1:$DT$5000").AutoFilter Field:=17, Criteria1:="="
ActiveSheet.Range("$A$1:$DT$5000").AutoFilter Field:=15, Criteria1:="<>"
Range("O1:P631").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SFR Submit").Select
Range("A23").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I am looking for help to make the Field=17/Field=15 and the Range ("O1:P631") be selected from the relevant output sheets.
Help!!
I need vba code to copy everything starting from A5, everything to the right of it and down to the last row in one workbook and paste it into another Workbook, starting at A5.
This is the code that I have so far, but it's not working.
Windows("Month By Month Income Statment 10.xlsx").Activate
Sheets("Month By Month Income Statmen-A").Select
Range("A5").Select
Dim EC As Long
Dim X As Long
Dim Y As Long
X = Range("A5").End(xlUp).Offset(1, 0).Row
EC = Range("A5").End(xlToLeft).Offset(0, X).Column
Range("A5" & EC).Select
Selection.Copy
Windows("RPG - Apr Mnth acs by co.xlsm").Activate
Sheets("010 - RPL").Select
Range("A5").Select
ActiveSheet.Paste
End Sub
I noticed you had another question to answer, so I had a go at this one too.
I know it wasn't in your original request, but I've added a section that clears the contents of the "RPG" file first (Only from row 5 downwards), so that you won't run in to any problems. This way you will always have a blank page to paste your new data in to and you'll never have data left over from last time if your new data is smaller than your old data. If you don't need this bit feel free to leave it out.
Sub Get_New_Data_From_Other_Workbook()
'
' This macro will copy data from a .xlsx file and paste it back into the .xlsm file
' Any contents in the .xlsm file will first be deleted
' Clear the existing contents of the destination sheet
Windows("RPG - Apr Mnth acs by co.xlsm").Activate ' Make sure the RPG file is selected
Sheets("010 - RPL").Select ' Select the required sheet
Range("A5").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select ' From A5, select every cell until the end of the page (up to where the data stops)
Application.CutCopyMode = False
Selection.ClearContents ' Delete contents
Range("A1").Select ' Select A1 for presentation purposes
' Go to the correct sheet of the other workbook and copy the data
Windows("Month By Month Income Statement 10.xlsx").Activate ' Select the other workbook
Sheets("Month By Month Income Statmen-A").Select ' Select the sheet with the data on
Range("A5").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select ' From A5, select every cell until the end of the page (up to where the data stops)
Selection.Copy ' Copy the data
' Come back to the macro workbook and paste the data in A5 of the required sheet
Windows("RPG - Apr Mnth acs by co.xlsm").Activate ' Select the RPG file
Sheets("010 - RPL").Select ' Select the required sheet
Range("A5").Select ' Select cell A5
ActiveSheet.Paste ' Paste the data
Range("A1").Select ' Select A1 for presentation purposes
End Sub
My task is to create a searchable database within Excel with an entry form. I need a macro to take the data from the entry form move to the database sheet offset the active cell down 1 row and copy the values only(not the formatting)
Every time I try to run the macro I get a run-time error in the code. I have no experience with VB or VBA; please tell me what is wrong with this.
Sheets("Database").Select 'Navigates to Database worksheet
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If 'Clears filters
Sheets("Entry Form").Select 'Navigates back to Entry Form worksheet
Range("E10:L10").Select ' select date, period, and data
Selection.Copy
Sheets("datatable").Select ' navigate to datatable tab
Range("A1").Select
Selection.End(xlDown).Select ' ctrl-down to last occupied row,
ActiveCell.Offset(1, 0).Select ' then one more to first blank row
Selection.PasteSpecial Paste:=xlPasteValues
'Pastes data as values only into the Database worksheet
Sheets("Entry Form").Select 'Navigates to Entry Form worksheet
Application.CutCopyMode = False 'clears copy data from clipboard
Range("E10, L10").Select
Selection.ClearContents 'Clears data from drop down selections
Range("E10").Select 'Returns selection back to Date entry box
It goes the very bottom of the next page and gives a 1004 error.
You need more than just a column label in A1 if you are going to use xlDown. There has to be at least one more value in column A or you will traverse to the bottom of the worksheet. It is usually better to look from the bottom of the worksheet upwards and then offset one row down.
With Sheets("Database") 'Primarily use Database worksheet
If .FilterMode Then .ShowAllData
With .Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) 'look from bottom up then down 1 row
'direct value transfer is faster than Copy, Paste Special, Values
.Cells.Resize(1, 8) = Sheets("Entry Form").Range("E10:L10").Value
End With
End With
With Sheets("Entry Form") 'Primarily use Entry Form worksheet
.Range("E10:L10").ClearContents 'Clears data from drop down selections
.Range("E10").Select 'Returns selection back to Date entry box
End With
This makes use of the With ... End With statement to control which worksheet is receiving attention. See How to avoid using Select in Excel VBA macros for more methods on getting away from relying on select and activate to accomplish your goals.
Hello i need some help with a abit of code, basically i have a workbook which has a lot of data for product Accessories listed in rows in the columns next to these there are the products with blank fields in all of the cells, basically the point of this is when the user types an "x" in any of these cells the table is able to be filtered.
I have made a summary sheet where i want it to look at these specific columns for example columns E-N and if it contains an "x" it will copy the corresponding row which are A,B,C,D and paste it on this summary sheet one after another as well as copying the product from the row above all the x's
e.g
Column E has an x in E4,5,10,15,53
i want it to copy
ABCD4
ABCD5
ABCD10
ABCD15
ABCD53
as well as the product name e.g "melons" which is located just above the first blank box of each column in this case lets say E4 is the first blank so E3 would be the product name.
and paste it in a sheet called "Summary Sheet" one row after another.
I know this is really confusing but i hope you can help :)
code i have:
I now have this code and im almost at where i want to be i need help on the line
Range("A5").Select
It gives me an error but unless i select this cell it pastes randomly on the sheet
Private Sub CommandButton9_Click()
Range("A7:D7").Select
Range(Selection, Selection.End(xlDown)).Select ' Go to last line
' Add a filter behavior
Selection.AutoFilter Field:=5, Criteria1:="<>"
Range("A7:D7").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
' Paste data where you want
Sheets ("Summary Sheet")
Range("A5").Select
ActiveSheet.Paste
End Sub
The idea could be
Select your set of data
Apply filter to isolate rows with x as value for the filtering
column
Select data and do a copy / paste action
Proposed sample of code (should be adapted to your spreadsheets)
' Select your range of data - maybe
Range("A1:E1").Select
Range(Selection, Selection.End(xlDown)).Select ' Go to last line
' Add a filter behavior
Selection.AutoFilter Field:=5, Criteria1:="<>"
Range("A1:E1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
' Paste data where you want
Sheets("Feuil2").Select
Range("A1").PasteSpecial Paste:=xlPasteValues