小编mic*_*ler的帖子

从USEDRANGE方法中排除第一行(我的工作表中的第一行)?

我有一些来自我的经纪人的输入数据.我写了一些代码来自动计算,添加列和插入一些公式.

最后,我想做一些条件格式化(影响整行)来确定有利可图的事务(绿色字体整行)和丢失的事务(红色字体整行).

要做到这一点,我使用了USEDRANGE方法 - 我知道这是一个棘手的方法,我的数据是一致的 - 没有空行,只有几个空列,所以我认为USEDRANGE会处理它.我需要使用USEDRANGE,因为下次我将运行此报告时会有更多行.

但我在我的数据中有第一行,我将标题列为4列.

我希望我的标题保持黑色(字体),但我仍然想使用USEDRANGE方法.

在此输入图像描述

如何使用USEDRANGE方法执行条件格式,排除第一行(因此它保持黑色字体).

Option Explicit
Dim RowNumber As Long
Dim LastRow As Long
Dim ColumnNumber As Integer
Dim LastColumn As Integer
Dim VBA As Worksheet
Dim TotalRange As Range

Sub CondicionalFormating_WholeRows()
    Set VBA = Workbooks("lista transakcji Dukascopy od October 2015.xlsm").Worksheets("VBA")
    Set TotalRange = VBA.UsedRange
    LastRow = VBA.Cells(Rows.Count, 1).End(xlUp).Row
    LastColumn = VBA.Cells(1, Columns.Count).End(xlToLeft).Column

TotalRange.FormatConditions.Add Type:=xlExpression, Formula1:="=$H1<0"
TotalRange.FormatConditions(TotalRange.FormatConditions.Count).SetFirstPriority
    With TotalRange.FormatConditions(1).Font
        .Bold = False
        .Italic = False
        .Strikethrough = False
        .Color = -16777024
        .TintAndShade = 0 …
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba

7
推荐指数
2
解决办法
1万
查看次数

访问 VBA - 导入 *.CSV 时出现运行时错误 31519。您无法导入此文件

在 Access 中使用 DoCmd.TransferText 方法时,我收到问题标题中描述的错误。我的代码从当前数据库的表中获取文件名(这些文件是从单个文件夹中存在的 2000 个以上文件中选择的),其目标是将这些文件的内容导入到 Access 中的一个表中。请阅读本主题以获取更多信息: VBA procedure to import only selected csv files (from onefolder) into a single table in access

所有文件都具有相同的结构和数据类型。在此输入图像描述

这是我正在使用的代码:

 Sub Importing_data_into_a_single_table_csv_version()
   Dim my_path As String
   Dim rs As Recordset
   Dim start As Double
   Dim total_time As String

     DoCmd.SetWarnings True
     my_path = "C:\Users\michal\SkyDrive\csv\bossa\mstcgl_csv\"     ' source folder.

     start = Timer         ' remember time when macro starts.

     Set rs = CurrentDb.OpenRecordset("CSV Files")   ' opens the table with file names.
       Do Until rs.EOF
          If Dir(my_path & …
Run Code Online (Sandbox Code Playgroud)

csv ms-access vba

6
推荐指数
1
解决办法
4478
查看次数

标签 统计

vba ×2

csv ×1

excel ×1

excel-vba ×1

ms-access ×1