-
Nov 6th, 2020, 11:32 AM
#1
Thread Starter
New Member
Create user input box for range row in Excel
I have recorded macro to copy (A3:M3) and paste specific cells (A3:M3) to another workbooks specific cells(A3:M3).
My problem is that I would like to create a command button to do function,
BUT have the ability to change row value
IE: if I select 3 in row input box it copies cells(A3:M3)
if I select 4 in row input box it copies cells(A4:M4)
if I select 5 in row input box it copies cells(A5:M5)
the cells will ALWAYS be pasted into the same target cells in 2nd workbook (A3:M3)
any suggestions (I am trying to create a command to create an estimate from call log entry)
Sub testcopy()
'
' testcopy Macro
'
'
Range("A3:M3").Select
Selection.Copy
Windows("Mid Template rev56.xltm").Activate
Workbooks.Open Filename:= _
"C:\Users\AY\Memphis\Custom Office Templates\Mid Template rev56.xltm" _
, Editable:=True
Sheets("DASHBOARD").Select
ActiveWindow.SmallScroll Down:=-51
Range("A3:M3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("(CALL LOG).xlsx").Activate
End Sub
-
Nov 7th, 2020, 03:43 AM
#2
Re: Create user input box for range row in Excel
use CODE TAGS when posting your code, makes it so much easier to read
try like this in your command button
Code:
rw = inputbox("Enter first row number")
cells(rw, 1).resize((, 13).copy
Set wb= Workbooks.Open(Filename:= _
"C:\Users\AY\Memphis\Custom Office Templates\Mid Template rev56.xltm" _
, Editable:=True)
wb.sheets("dashboard"),cells(3, 1).pastespecial, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.close True ' save and close or omit if you want to leave open
though i am not sure you should be editing a template file every time, more likely open a new file based on the existing template
i only typed this in the browser, so may contain typos or code errors
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|