27、利用VBA创建和操作数据透视表

利用VBA创建和操作数据透视表

在数据处理和分析领域,Excel的数据透视表功能无疑是一项强大且创新的工具。它能让我们以独特的方式汇总数据,速度快且无需复杂公式。而VBA(Visual Basic for Applications)则为我们自动化创建和修改数据透视表提供了可能。下面将详细介绍如何使用VBA来创建和操作数据透视表。

1. 数据透视表简介

数据透视表自Excel 5版本就已出现,并且在后续版本中不断改进。使用数据透视表,我们可以从数据库或列表中汇总数据,实现手动操作难以完成的数据分析。同时,我们还能通过编写VBA代码来生成和修改数据透视表。

2. 简单数据透视表示例

假设有一个包含销售代表、地区、月份和销售额四个字段的工作表范围,我们可以基于这些数据创建一个数据透视表,以按销售代表和月份汇总销售业绩。

以下是使用Excel 2016宏录制器生成的创建数据透视表的代码:

Sub CreatePivotTable()
    Sheets.Add 
    ActiveWorkbook.PivotCaches.Create _ 
        (SourceType:=xlDatabase, _
        SourceData:="Sheet1!R1C1:R13C4", _
        Version:=6).CreatePivotTable _ 
        TableDestination:="Sheet2!R3C1", _ 
        TableName:="PivotTable1", _
        DefaultVer
微软MOS认证学习工具开发与VBA技术实践 办公软件自动化是提升工作效率的关键技术,其中VBA作为Office内置的编程语言,能够实现文档处理、数据操作等复杂任务的自动化执行。通过录制宏和XML结构比对等技术,可以构建智能批改系统,显著提升操作准确性检测效率。这类技术在教育培训领域具有重要应用价值,特别是在认证考试辅助工具开发中,能够实现考纲解析、模拟题库、实操演示等核心功能。本文介绍的微软MOS认证学习工具,正是基于VBA和NLP技术,解决了考生在Office操作录制、环境差异适配等典型问题,使备考效率提升42%,首次通过率达到89%。 阅读详情

相关推荐

别再手动记代码了!用这个开源VBA工具箱,把Excel变成你的私人代码库

本文介绍了一款开源VBA工具箱,帮助Excel用户高效管理代码库,避免重复编写和查找代码的烦恼。通过智能检索、深度集成和即插即用功能,大幅提升工作效率,特别适合金融分析、报表自动化等场景。

weixin_28713947的博客 393

BOM和MRP实战指南:如何用Excel快速搭建简易物料管理系统

本文为初创团队和小型企业提供了一份实用的BOM和MRP实战指南,详细讲解如何利用Excel快速搭建一个简易的物料管理系统。通过设计核心数据表、运用函数实现MRP逻辑计算,并结合数据透视与自动化技巧,帮助用户有效管理物料清单、优化库存并制定采购计划,从而提升供应链管理效率。

sre5engineer的博客 819

重学 VBA - 基础与实战篇(含正则表达式)

目录1. 单元格对象与方法1.1 End 方法1.2 SpecialCells 方法 1. 单元格对象与方法 1.1 End 方法 【应用】:查找最后一行 标准写法(不是63336 ,也不是1048576): Cells( Rows.Count, 1).End ( xlUp ) Cells( Columns.Count, 1).End ( xlToLeft ) 这样,不管是Excel 2003 版本(最大65536行)还是Excel 2007 及以后版本(最大1048576行),都不会报错。

←か淡定☆ ヾ 的博客 745

EXCEL VBA从入门到精通 前言

本书通过丰富的实例和案例,帮助读者更好地理解和应用Excel VBA编程,同时也介绍了常用的工具、资源、社区和协作平台等,方便读者进行进一步的学习和开发。我强烈推荐这本书给所有希望学习和掌握Excel VBA编程的读者。多样化的资源和工具介绍:本书介绍了丰富的工具和资源,包括官方文档、在线教程、代码库、论坛、博客等,方便读者进行进一步的学习和开发。详细的讲解和丰富的示例:本书从语法和对象开始讲解,通过丰富的实例和案例,帮助读者更好地理解和应用Excel VBA编程。第一节:什么是VBA 5。

1753

27、Excel数据处理与分析全攻略

本文全面介绍了Excel在数据处理与分析中的各项核心技能,涵盖软件许可协议、数据操作基础、图表制作、公式与函数应用、VBA自动化编程、数据透视表、数据库连接、数据分析工具使用、数据安全保护以及功能自定义扩展等内容。通过系统讲解与图示,帮助读者掌握从基础输入到高级分析的全流程技术,提升数据处理效率与决策支持能力。

gin88的博客 101

DTS 数据迁移

支持关系型数据库(MySQL, Oracle, SQL Server等)、NoSQL数据库、大数据系统等。DTS数据迁移是现代化数据架构调整和云迁移过程中的重要工具,能够大大降低数据迁移的复杂度和风险。DTS (Data Transmission Service) 是一种数据迁移和同步服务,:先迁移历史数据(全量),再实时同步新增变化(增量):不同数据库类型间迁移,如Oracle到MySQL。:将单库数据迁移到分库分表架构。:将业务数据迁移到分析型数据库。:将本地数据库迁移到云数据库。

qq_41081716的博客 752

手把手教你用Kali+字典爆破WiFi密码:从抓包到破解的完整流程

本文提供了一份详尽的无线网络渗透测试实战指南,重点讲解如何使用Kali Linux和Aircrack-ng套件进行WiFi安全评估。内容涵盖从硬件选型(如RTL8812AU网卡)、驱动配置、监听模式设置,到使用airodump-ng扫描抓包、捕获WPA握手包,以及利用字典进行离线破解的完整流程。同时强调了在授权环境下进行安全测试的重要性,并给出了相应的网络加固建议。

weixin_28568819的博客 1685

别再为GEE注册发愁了!用谷歌Cloud Project,5分钟搞定谷歌地球引擎账户(保姆级图文)

本文提供2024最新版谷歌地球引擎(GEE)账户注册的保姆级教程,通过谷歌Cloud Project快速完成注册,5分钟极速通关。详细解析注册前的准备、分步图解流程、常见误区及解决方案,帮助用户避开90%的注册陷阱,直达GEE核心功能区。

weixin_42557830的博客 216

Redis+QMT实战:如何用Stream模式实现聚宽策略的毫秒级跟单(附完整代码)

本文详细介绍了如何利用Redis Stream模式构建一个低延迟、高可靠的量化交易信号中继系统,实现从聚宽策略到本地QMT的毫秒级跟单。通过对比传统方案,解析了Redis Stream在消息持久化、消费组和显式确认方面的核心优势,并提供了完整的架构设计思路与核心代码实现,帮助量化开发者解决云端策略信号稳定传递至本地实盘的难题。

weixin_29280657的博客 481

【PB03F 超详细-环境搭建】蓝牙5.2安信可PB-03F-Kit开发板二次开发环境搭建

PB-03是由深圳市安信可科技有限公司开发的蓝牙模块。本博文介绍安信可PB-03F-Kit开发板的基本情况、开发环境搭建,以及以点亮LED为例介绍程序编写和固件烧录的操作流程。 安信可PB-03F-Kit开发板使用的PHY6252这样一款高集成度的低功耗蓝牙系统级芯片(SoC),专为物联网(IoT)、移动设备、可穿戴电子设备、智能家居等各种应用而设计。......

qq_44078824的博客 1万+

使用 vLLM 和 YaRN 扩展技术部署 Qwen3-32B 大模型:实现 80K 长文本推理

vLLM 是一个高性能的 LLM 推理和服务引擎,以其高效的注意力机制(PagedAttention)和优异的内存管理著称。它提供了与 OpenAI API 兼容的接口,使得现有应用可以无缝迁移。通过vLLM与YaRN技术的结合,我们成功将Qwen3-32B的上下文处理能力从32K扩展到80K,为长文本应用场景提供了强大的技术支持。这种部署方案兼具高效性和实用性,是处理大模型长上下文需求的优选方案。随着硬件和算法的不断进步,我们期待看到更大上下文窗口的模型服务成为可能。延伸阅读vLLM官方文档。

Ven%的博客 1752

一文读懂OpenClaw:核心组件与工作原理深度解析

Agent核心:负责理解意图、规划任务、协调执行消息系统:统一的消息格式,实现组件间解耦工具注册表:可扩展的工具系统,支持自定义工具模型适配层:多模型支持,统一API接口安全机制:沙箱隔离、权限确认、操作审计性能优化:并行执行、智能缓存、增量更新理解这些核心组件和工作原理,将帮助你更好地使用OpenClaw,也为后续开发自定义扩展打下坚实基础。在下一篇文章中,我们将详细介绍OpenClaw的界面操作,包括命令行与交互模式的各种技巧。

gaoxiang_120的专栏 838

Python学习第1天:初识Python

Python 作为目前最流行的编程语言之一,凭借其简洁优雅的语法和强大的生态系统,成为了无数开发者的首选。本系列文章将带你从零基础入门,逐步掌握 Python 编程的核心技能。今天我们先来认识 Python,并安装好开发环境。Python(英式发音:/ˈpaɪθən/;美式发音:/ˈpaɪθɑːn/)是由荷兰人吉多·范罗苏姆(Guido von Rossum)发明的一种编程语言,是目前世界上最受欢迎和拥有最多用户的编程语言。

tigerhhzz的博客 443

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 49、神经元动作电位的产生、重复放电及相关特性解析
下一篇: 34、小波分解结构处理与逆快速小波变换
python9snake
博客等级 码龄1天 0粉丝 1724原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址