[英]Need a Macro to autofill down “x” rows after data input
Please if possible, could use some help with a Macro I have written out. 如果可能的话,请对我编写的宏使用一些帮助。 The macro pastes a range of data to the active spreadsheet.I then have a inputbox that allows the user to input a selection into the first row of Column A in the new selection.
宏将一系列数据粘贴到活动电子表格中,然后我有一个输入框,允许用户将选择内容输入到新选择项的A列第一行中。 All I need is for the selection to paste down 3 rows of what they enter into instead of one( with formatting intact).
我所需要做的就是选择将其输入的内容粘贴3行而不是粘贴(完整保留格式)。 I hope this makes sense and happy to clarify anything.
我希望这很有意义并且很高兴澄清任何事情。
Thank for you any help you can give me. 谢谢您能给我的任何帮助。
Code Below: 下面的代码:
Sub NewSection()
'adds a new section to the last row of the active spreadsheet'
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("zDATA")
Set pasteSheet = ActiveSheet
copySheet.Range("ClientSection").Copy
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.ScreenUpdating = True
'Text box for entering client name into the new section'
Dim ans As String, lr As Long
ans = InputBox("Enter Client Name", "Data Entry Form")
If ans = "" Then
Exit Sub
Else
lr = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("A" & lr).Value = ans
End If
End Sub
由Virtual David和Foxfire回答!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.