Excel VBA在A行中的每个可见单元格,在H行中插入值? [英] Excel vba for each visible cell in A row, insert value in H row ?

查看:134
本文介绍了Excel VBA在A行中的每个可见单元格,在H行中插入值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用vba根据excel中A行的可见性状态在H行中插入值?

How do I insert value in the H row based on the visibility status of A row in excel using vba?

Dim rng As Range 
    Set rng = Range("A2", Range("A65536").End(xlUp)).SpecialCells(xlCellTypeVisible) 
    For Each cell In rng 
         rng.value = "Something"
    Next cell 

上面的代码会将某物"填充到A行,但是我不知道如何将其映射到H行(我想要的位置)?任何人都有任何想法...

The code above will populate 'something' to A row, but I don't know how to map this to H row (where) I want it ? Anyone have any ideas...

推荐答案

您可以在迭代中使用每个cellRow属性来映射到H列中的正确行

You can use the Row property of each cell in your iteration to map to the correct row in column H

Sub Macro1()
Dim rng As Range
    Set rng = Range("A2", Range("A65536").End(xlUp)).SpecialCells(xlCellTypeVisible)
    For Each cell In rng
        Range("H" & cell.Row).Value = "Something"
    Next cell
End Sub

这篇关于Excel VBA在A行中的每个可见单元格,在H行中插入值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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