用一个值连接一个范围

我试图连接一个单一的值的范围。

Sub Macro1() Dim rngOne As Range, strngOne as String, combos As Range 'finds the last row and sets it as the ending range Dim LastRowColC As Integer LastRowColC = Range("C65536").End(xlUp).Row Set rngOne = Worksheets(1).Range("C3" & LastRowColC) strngOne = "00000" combos = rngOne & strngOne Range("D3").Select Insert combos End Sub 

为什么不把variables“组合”插入单元格?

更多解释(复制自评论)

基本上我想要在C列的每个单元格中的值,并将00000添加到所有这些的结尾。 所以如果C1是50,我想最终的结果是复制50,并用5000000代替C1,如果C2是575,那么用57500000代替它,所有的数据范围都在C.

如果这是不可能的,我宁愿将它粘贴在同一列的值。 那么对于你给我的例子,我想要D1 = AAA00000,D2 = BBB00000,D3 = CCC00000等

这是你正在尝试? 我给了你两个方法。

方法1

 Sub Sample() Dim ws As Worksheet Dim lRow As Long Dim rng As Range '~~> Change this to the relevant worksheet Set ws = ThisWorkbook.Sheets("Sheet1") With ws '~~> Get last row in Col C lRow = .Range("C" & .Rows.Count).End(xlUp).Row '~~> Construct your range Set rng = .Range("C3:C" & lRow) '~~> Multiply all the cells in the range with 100000 '~~> so that 55 become 5500000, 123 becomes 12300000 and so on rng.Value = Evaluate(rng.Address & "*100000") End With End Sub 

方法2

在D1单元格中键入100000 ,然后运行此macros

 Sub Sample() Dim ws As Worksheet Dim lRow As Long Dim rng As Range '~~> Change this to the relevant worksheet Set ws = ThisWorkbook.Sheets("Sheet1") With ws '~~> Get last row in Col C lRow = .Range("C" & .Rows.Count).End(xlUp).Row '~~> Construct your range Set rng = .Range("C3:C" & lRow) '~~> This cell has 100000 .Range("D1").Copy '~~> Paste Special Value/Multiply rng.PasteSpecial Paste:=xlPasteValues, _ Operation:=xlMultiply, _ SkipBlanks:=False, _ Transpose:=False Application.CutCopyMode = False End With End Sub