在Excel中生成宏 [英] Generating macros in excel

查看:123
本文介绍了在Excel中生成宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在处理一些Excel工作表,其中包含4列,每列具有1000个值.最近,我了解了宏的简单性和快捷性,并希望在我的文件中尝试使用该宏来生成图表.在生成图表的代码中:

Hi all,

I''m working on some excel sheets, that contains 4 columns, each with 1000 values. I recently learnt how simple and quicker macros are and wanted to try that on my file to generate charts. In a code to generate a chart :

Sub CreateChart()
   Range("C3").Select
   Selection.CurrentRegion.Select
   myrange = Selection.Address
   mysheetname = ActiveSheet.Name
   ActiveSheet.ChartObjects.Add(125.25, 60, 301.5, 155.25).Select
   Application.CutCopyMode = False
   ActiveChart.ChartWizard _
     Source:=Sheets(mysheetname).Range(myrange), _
     Gallery:=xlLine, Format:=4, PlotBy:=xlRows, _
     CategoryLabels:=1, SeriesLabels:=1, HasLegend:=1, _
     Title:="", CategoryTitle:="", _
     ValueTitle:="", ExtraTitle:=""

(此代码来自Microsoft支持)
这段代码选择了从A1到D5的所有数据,但是我只想选择一列.我该怎么做?

(This code is taken from the Microsoft support)
this code selects all the data from A1 to D5, but I just want to select one column. How can I do that ?

推荐答案

最简单的方法是记录一个宏以执行所需的操作.因此,您可以开始记录宏,选择一列,停止宏,然后查看代码.

或者,这样做

The easiest thing to do is to record a macro doing what you want. So, you could start recording a macro, select one column, stop the macro and then look at the code.

Or, do this

Range("A:A").Select


这篇关于在Excel中生成宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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