excel vba插入行格式 [英] excel vba insert row with formatting

查看:236
本文介绍了excel vba插入行格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个宏插入一些行取决于Excel 2007中的用户输入。一切正常,但我仍然有一个小问题。我想从上面的行复制完整的格式。它只适用于行中的某些单元格。



这里是插入代码:

 行(B:B)插入Shift:= xlDown,CopyOrigin:= xlFormatFromLeftOrAbove 

是否有可能改变它?



最好,美国

解决方案

我不确定你是如何插入你的行的,但是如果你在现有行的下面插入行,默认情况下它会在上面的行上格式化,至少当你使用这种类型时的语法:

 范围(B2)。EntireRow.Offset(1,0).Insert 
< code


$ b在这个例子中,它将在B2下面插入一行,格式(比如B2的行被高亮显示为黄色)会变成黄色好。这可能与这种插入类型指定在哪一行插入的事实有关。


I have a macro which inserts a number of rows depending on user input in Excel 2007. Everything works but I still have a minor issue. I want to copy the complete formatting from the row above. It only works for some cells in the row.

Here is the code for insertion:

 Rows("B:B").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

Is it possible to change it?

best, US

解决方案

I am not sure exactly how you are inserting your rows, but if you insert the row below an existing one, it will by default take on the formatting of the row above it, at least it does when you use this type of syntax:

Range("B2").EntireRow.Offset(1, 0).Insert

In this example, it will insert a row below B2 and the format (say, B2's row is highlighted yellow) will be yellow as well. It might have to do with the fact that this type of inserting specifies exactly under which row to insert.

这篇关于excel vba插入行格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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