Excel VBA自定义序列 [英] Excel VBA Custom Sequence

查看:89
本文介绍了Excel VBA自定义序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Excel VBA,我正在尝试创建自定义序列.如何为范围为10.168.187.0-10.168.187.100的IP地址继续自定义序列?

Using Excel VBA, I am trying to create a custom sequence. How can I continue a custom sequence for a range of IP Addresses ranging from: 10.168.187.0 - 10.168.187.100?

我到目前为止的代码发布在下面.

The code I have so far is posted below.

Sub Sequence()
'
' Sequence Macro
' Macro recorded 13/02/2013 by Don
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Range("A1").Select
ActiveCell.FormulaR1C1 = "10.168.187.0"
Range("A2").Select
ActiveCell.FormulaR1C1 = "10.168.187.1"
Range("A3").Select
ActiveCell.FormulaR1C1 = "10.168.187.2"
Range("A4").Select
End Sub

推荐答案

假设您要自动执行单元格的完成,则应该可以进行以下操作:

Assuming that you're looking to automate the completion of the cells, the following should work:

Sub CompleteRange()

For i = 1 To 101

    Cells(i, 1) = "10.168.187." & (i - 1)

Next i

End Sub

这篇关于Excel VBA自定义序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆