首页 > 其他分享 >Excel 使用VBA 自定义函数

Excel 使用VBA 自定义函数

时间:2023-04-30 14:55:24浏览次数:30  
标签:VBA End String 自定义 Excel bit3 bit2 bit1 bit0

 

  • 启用Excel开发工具

 

 

 

  •  打开Excel 的VBA (ALT+F11)

 

 

  •  新键VBA工程模块
  • 写入自定义函数
Function HexIPAddr(strIPAddr As String, isAsc As Boolean) As String
    
        Dim arry, bit0 As String, bit1 As String, bit2 As String, bit3 As String
        arry = Split(strIPAddr, ".")

        bit0 = Hex(arry(0))
        bit1 = Hex(arry(1))
        bit2 = Hex(arry(2))
        bit3 = Hex(arry(3))
        
        
        If Len(bit0) = 1 Then
        bit0 = "0" + bit0
        End If
    
        If Len(bit1) = 1 Then
        bit1 = "0" + bit1
        End If
        
        If Len(bit2) = 1 Then
        bit2 = "0" + bit2
        End If
        
        If Len(bit3) = 1 Then
        bit3 = "0" + bit3
        End If
        
        
        If isAsc = True Then
                HexIPAddr = bit0 + bit1 + bit2 + bit3
        Else
                HexIPAddr = bit3 + bit2 + bit1 + bit0
        End If
        
                   
    End Function
  • 另存为 启用宏 的工作簿

 

  • 重新打开即可使用刚刚创建的自定义函数

 

标签:VBA,End,String,自定义,Excel,bit3,bit2,bit1,bit0
From: https://www.cnblogs.com/jianxiaoxiu/p/17365286.html

相关文章

  • C# 连接EXCEL 文本框保存输入信息
    部分代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingSystem.Data.OleDb;namespac......
  • Typora自定义图片图床服务器
    0x01启用picgo文件-偏好设置-图像-上传服务设定-PicGo-core(commandline)0x02安装插件打开路径C:\Users\你的用户名\.picgo(其他环境自己百度吧,我这是Windows),然后输入命令(得确保PC已有Node环境,不然npm报没有命令):npminstallpicgo-plugin-web-uploader0x02服务器返回接......
  • Python 基于win32com客户端实现Excel操作
    测试环境Python3.6.2代码实现非多线程场景下使用新建并保存EXCELimportwin32com.clientfromwin32apiimportRGBdefsave_something_to_excel(result_file_path):excel_app=win32com.client.Dispatch('Excel.Application')excel_app.Visible=False#设......
  • csv用Excel打开出现乱码
    CSV用Excel打开出现乱码今天出现一个问题使用wps打开不会出现乱码。但使用excel打开的时候会出现乱码。其实在我们把文件流转成文件的时候需要在bolb对象前加上unicode标识,只需要下载的时候在数据流前面新增一个标识就行了。还有一点需要记住,res一定是blob对象,所以看......
  • chipyard——自定义配置生成和前仿
    一,生成配置前面用rocket-chip仓库做了生成和前仿,为了方便扩展外设,这里转到chipyard仓库。首先我们生成一个之前用的配置: 为删SimDTM(我的测试框架不需要),先在rocket的subsystem/config下创建一个class: 然后在chipyard顶层创建config: makeCONFIG=MyConfig创建设计 发......
  • nginx自定义指定加载配置
    进入 /usr/local/nginx/conf/include目录,创建 nginx.node.conf文件,在里面输入如下代码:upstreamnodejs{server127.0.0.1:3000;#server127.0.0.1:3001;keepalive64;}server{listen80;server_namewww.penguu.compenguu.com;access_lo......
  • 如何自定义starter
    背景使用过SpringBoot的小伙伴都应该知道,一个SpringBoot项目就是由一个一个starter组成的,一个starter代表该项目的SpringBoot启动依赖,除了官方已有的starter,我们可以根据自己的需要自定义新的starter。我们经常会看到或者使用到各种***-starter。比如下面几种:spring-boo......
  • Spring 实现自定义 bean 的扩展
    Springmvc提供了扩展xml的机制,用来编写自定义的xmlbean,例如dubbo框架,就利用这个机制实现了好多的dubbobean,比如 <dubbo:application>、<dubbo:registry> 等等,只要安装这个标准的扩展方式实现配置即可。扩展自定义bean的意义何在假设我们要使用一个开源框架或者一套......
  • vue3自定义指令实现el-select下拉加载更多
    1.新建js文件exportdefault(app)=>{app.directive('loadmore',{beforeMount(el,binding){constelement=el.querySelector('.t-select__dropdown');element.addEventListener('scroll',()=>{co......
  • CMakeLists---自定义变量-add_definitions()函数
    转载:https://blog.csdn.net/qq_35699473/article/details/115837708引言其实这个函数在安装一些库的时候,它的CMakeLists里面就有这样的函数。典型的就是opencv了。opencv安装时候有一些指令也是针对这个函数的,比如安装命令(随便搜索的):cmake ../opencv-3.4.1-DWITH_GTK_2......