免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Excel讓選定單元格所在行和列顏色突出高亮顯示

Excel讓選定單元格所在行和列顏色突出高亮顯示


當(dāng)工作表里面的數(shù)據(jù)量大的時候,鼠標(biāo)選定當(dāng)前單元格后,要想弄清楚它對應(yīng)的行和列實(shí)在是不方便。如果能做到excel自動以高亮突出顏色的方式來顯示當(dāng)前行和列的話,那該多方便啊,哈哈。其實(shí)excel中可以做到這個效果的,方法有兩種:條件格式和vba。

使用條件格式

下面將使用條件格式實(shí)現(xiàn)當(dāng)前單元格和當(dāng)前單元所在行或列突出顯示的效果。

在公式中使用了cell函數(shù),并將screenupdation屬性的值設(shè)置為true以實(shí)現(xiàn)屏幕更新。

在thisworkbook模塊中輸入如下代碼: private sub workbook_sheetselectionchange(byval sh as object, byval target as range) application.screenupdating = true end sub 當(dāng)然,如果只想在工作表中實(shí)現(xiàn)突出顯示的效果,將application.screenupdating = true代碼輸入到worksheet_selectionchange事件中。

接下來,在excel中選擇菜單“格式——條件格式”命令,彈出“條件格式”對話框。

在“條件”下拉框中選擇“公式”并在右側(cè)中輸入下面相應(yīng)的公式,然后點(diǎn)擊“格式”按鈕,設(shè)置相應(yīng)的格式,完成后,按“確定”按鈕。

下面是相應(yīng)的公式及其作用: (1)公式“=cell("address")=address(row(),column())”,突出活動單元格,如下圖1所示。

 

圖1

(2)公式“=cell("row")=row()”,突出單元格所在行,如下圖2所示。

 

圖2

(3)下面的公式突出到當(dāng)前單元格為止的相應(yīng)行和列,呈反l形,如下圖3所示。 “=or(and(cell("row")=row(),cell("col")+1>column()),and(cell("col")=column(),cell("row")+1>row()))”

 

圖3

(4)在“條件格式”對話框中對所選單元格區(qū)域設(shè)置兩個如下所列的公式條件,將呈反l形突出顯示到當(dāng)前單元格為止的相應(yīng)行和列,且當(dāng)前單元格背景色改變、字體加粗顯示,如下圖4所示。 “=cell("address")=address(row(),column())” “=or(and(cell("row")=row(),cell("col")+1>column()),and(cell("col")=column(),cell("row")+1>row()))”

  圖4  示例文檔見 使用條件格式自動突出顯示.xls。

使用vba代碼
(1) 突出顯示至當(dāng)前單元格所在的行和列,呈反l形。在需要設(shè)置此功能的工作表模塊中輸入下面的代碼:
private sub worksheet_selectionchange(byval target as range)
  dim icolor as integer
  '注:如果工作表中有想要保留的條件格式,則不要使用本程序
  '忽略用戶選擇單元格區(qū)域時可能產(chǎn)生的錯誤
  on error resume next
  icolor = target.interior.colorindex
  if icolor < 0 then
    icolor = 36
  else
    icolor = icolor + 1
  end if
  '避免字體顏色與突出色相同
  if icolor = target.font.colorindex then icolor = icolor + 1
  cells.formatconditions.delete
  '水平突出色
  with range("a" & target.row, target.address)
    .formatconditions.add type:=2, formula1:="true"
    .formatconditions(1).interior.colorindex = icolor
  end with
  '垂直突出色
  with range(target.offset(1 - target.row, 0).address & ":" & _
    target.offset(-1, 0).address)
    .formatconditions.add type:=2, formula1:="true"
    .formatconditions(1).interior.colorindex = icolor
  end with
end sub
注意,此代碼運(yùn)行后,將清除所在工作表中含有的條件格式。示例文檔見 用顏色自動突出顯示當(dāng)前單元格行列1.xls。uploadfiles/2006-10/1027319888.rar
(2) 突出顯示當(dāng)前單元格所在的行和列。在需要設(shè)置此功能的工作表模塊中輸入下面的代碼:
private sub worksheet_selectionchange(byval target as range)
  '可帶條件格式,但不能復(fù)制/剪切/粘貼操作
  with target.parent
    .cells.interior.colorindex = 0
    .columns(target.column).cells.interior.colorindex = 35
    .rows(target.row).cells.interior.colorindex = 35
  end with
end sub
注意,此代碼運(yùn)行后,在當(dāng)前工作表中不能進(jìn)行復(fù)制、剪切和粘貼功能。示例文檔見 用顏色自動突出顯示當(dāng)前單元格行列2.xls。uploadfiles/2006-10/1027121529.rar
(3) 突出顯示當(dāng)前單元格所在的行和列。在需要設(shè)置此功能的工作表模塊中輸入下面的代碼:
private sub worksheet_change(byval target as range)
  if application.cutcopymode <> false then
    application.cutcopymode = false
    call colorband(target)
  end if
end sub
‘- - - - - - - - - - - - - - - - - - - - -
private sub worksheet_selectionchange(byval target as range)
  if application.cutcopymode = false then
    call colorband(target)
  else
    exit sub
  end if
end sub
‘- - - - - - - - - - - - - - - - - - - - -

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
excel自動為該單元格或者該單元格所在的行或列加上顏色_數(shù)據(jù)——>決策?方向?未來?_百...
WPS里有個聚光燈,可是我的Excel里沒有這個怎么辦?
高亮顏色標(biāo)記單元格、行、列、行列實(shí)例
Excel高亮顯示選中的單元格所在行和列的終極技巧
Excel行列十字交叉高亮顯示
VBA做excel聚光燈效果,只需一行代碼,你還要下載插件嗎?
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服