宏来引用excel上的单元格

时间:2016-03-21 09:27:02

标签: vba excel-vba macros excel

这是一个非常基本的问题,我对此很新。请帮助 我需要为sku和数量创建一个标签格式,然后打印出来 例如: 表1(采购订单表)有两个cloumn

Direction Reldir = Direction.valueOf(relation_direction); 
PathExpander<Object> expander = Traversal.pathExpanderForAllTypes(Reldir);  
PathFinder<Path> finder = GraphAlgoFactory.shortestPath(expander, maxDepth,1);         
Path path = finder.findSinglePath(first_node, second_node); 
PathPrinter pathPrinter = new PathPrinter("name");
Traversal.pathToString(path, pathPrinter); 

static class PathPrinter implements Traversal.PathDescriptor<Path> {
private final String nodePropertyKey;

    public PathPrinter(String nodePropertyKey) {
        this.nodePropertyKey = nodePropertyKey;
    }

    public String nodeRepresentation(Path path, Node node) 
     {
      System.out.println(node.getProperty(nodePropertyKey, "").toString()+" ");
     }

我有超过500行。

我需要以下格式的数据

Sku          Qty

Bracelets-BB003   6

Bracelets-BB004   8

Bracelets-BB029   5

这样我就可以将它们作为单独的标签进行打印和剪切

详情:表1名称:采购订单

输出格式:

Bracelets-BB003                   
      6                                




Bracelets-BB004      
      8

Bracelets-BB004 

请帮忙!

2 个答案:

答案 0 :(得分:0)

如果我理解你的问题,应该这样做:

$ActiveDirectoryList=@() 
$UserDetails = get-aduser -filter {enabled -eq $true} -properties * | Select DisplayName,EmailAddress, SAMAccountName
$counter = 0
foreach($User in $UserDetails){

    $ActiveDirectoryList = New-Object PSObject
    $Users = get-aduser $User.SAMAccountName -properties * 
    if(!$Users.EmailAddress -eq ""){
        $counter++
        $ActiveDirectoryList | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $Users.DisplayName
        $ActiveDirectoryList | Add-Member -MemberType NoteProperty -Name "Email Address" -Value $Users.EmailAddress 
        write-host $Users.DisplayName
        $ActiveDirectoryList+=$ActiveDirectoryList
    }
}

请注意,您必须调整循环中的引用和行号才能使其正常工作,因此请阅读注释。

答案 1 :(得分:0)

试试这个

Option Explicit

Sub LabelPrint()

Dim skuNumberSht As Worksheet, labelsSht As Worksheet
Dim iniRow As Long, lastRow As Long

Set skuNumberSht = ThisWorkbook.Sheets("SkuNumber") ' <== change "input" sheet name as per your needs
Set labelsSht = ThisWorkbook.Sheets("Labels") ' <== change "output" sheet name as per your needs

With skuNumberSht.Columns("B").SpecialCells(xlCellTypeConstants, xlNumbers) '<== change "Qty" column index as per your needs
    iniRow = .Rows(1).Row
    lastRow = .Areas(.Cells.Count).Row
End With

With labelsSht.Cells(iniRow, 1).Resize(2)
    .Formula = Application.WorksheetFunction.Transpose(Array("=" & skuNumberSht.Name & "!RC", "=" & skuNumberSht.Name & "!R[-1]C[+1]"))
    .Copy .Resize(lastRow - iniRow + 2)
End With

End Sub

它适用于“输入”工作表中的任何行,只要它们“配对”(一行包含两列数据和一行空行)

您只需根据需要使用“数量”更改工作表名称和列索引。