How to print the values of cells

T

tannu

Hi All

Below code compares and gives the result in numbers.What I want is
instead it gives number like 2 or 3 it should gives the names.So how
can I print the contents of the cells after it does sum.
Thanks for your help

Sub HCL()

Dim self As Workbook
Set self = ActiveWorkbook

Dim Table1 As Worksheet
Dim NetworkDrivers As Worksheet
Set Table1 = self.Worksheets(1)
Set NetworkDrivers = self.Worksheets(2)

Table1_usedRow = Table1.UsedRange.Row + Table1.UsedRange.Rows.Count -
1
NetworkDrivers_usedRow = NetworkDrivers.UsedRange.Row +
NetworkDrivers.UsedRange.Rows.Count - 1
NetworkDrivers_usedCol = NetworkDrivers.UsedRange.Column +
NetworkDrivers.UsedRange.Columns.Count - 1

For i = 2 To NetworkDrivers_usedRow
drivers = UCase(Trim(NetworkDrivers.Cells(i, 1)))

For j = 2 To NetworkDrivers_usedCol
project = UCase(Trim(NetworkDrivers.Cells(1, j)))
Sum = 0
For c = 2 To Table1_usedRow
If UCase(Trim(Table1.Cells(c, 8 )) = drivers Then
If UCase(Trim(Table1.Cells(c, 9))) = project Then
Sum = Sum + 1
End If
End If
Next c
NetworkDrivers.Cells(i, j) = Sum
Next j
Next i
 
T

tannu

Hi Joel
Thank for your reply.
I don't want to print the results ,what I want to say is.

My code compares two values that is network drivers(second xls sheet)
with table1(first xls sheet) then it results in numeric numbers.
Say example particular network driver is cell 1 of network drivers.xls
is used 3 times in table1.So the 3 times is for a particular feature.
So I want it to display the feature name instead of the numeric 3.

Thanks for your help.
 
J

Joel

Where is the feature name located?

tannu said:
Hi Joel
Thank for your reply.
I don't want to print the results ,what I want to say is.

My code compares two values that is network drivers(second xls sheet)
with table1(first xls sheet) then it results in numeric numbers.
Say example particular network driver is cell 1 of network drivers.xls
is used 3 times in table1.So the 3 times is for a particular feature.
So I want it to display the feature name instead of the numeric 3.

Thanks for your help.
 
T

tannu

Hi joel

feature names located in first sheet (table1).

Table 1 xls has : first xls
hostname network drivers feature
x e100 install
y tgx upgrade
z e100 install

network drivers (second xls)
network driver Install
e100 2
tgx 1


So instead of "2" I would like the hostnames "x" and "z".

Thanks for help.
 
J

Joel

from
For j = 2 To NetworkDrivers_usedCol
project = UCase(Trim(NetworkDrivers.Cells(1, j)))
Sum = 0
For c = 2 To Table1_usedRow
If UCase(Trim(Table1.Cells(c, 8 )) = drivers Then
If UCase(Trim(Table1.Cells(c, 9))) = project Then
Sum = Sum + 1
End If
End If
Next c
NetworkDrivers.Cells(i, j) = Sum

to
For j = 2 To NetworkDrivers_usedCol
project = UCase(Trim(NetworkDrivers.Cells(1, j)))
MyString = ""
For c = 2 To Table1_usedRow
If UCase(Trim(Table1.Cells(c, 8 )) = drivers Then
If UCase(Trim(Table1.Cells(c, 9))) = project Then
if MyString = "" then
MyString = Table1.Cells(c, 8)
else
MyString = MyString & "," & Table1.Cells(c, 8)
end if
End If
End If
Next c
NetworkDrivers.Cells(i, j) = MyString
 
T

tannu

Hi Joel

Thaks for your reply.
After the change I am getting "e100 e100" unlike earlier I was getting
numeric "2" .
I would like to have the corresponding hostnames "x" and "z" instead
of "e100 e100".

Table 1 xls has : first xls
hostname network drivers feature
x e100 install
y tgx upgrade
z e100 install

network drivers (second xls)
network driver Install
e100 e100 e100 (I would like to have "x" and "y")
tgx tgx (I would like to have "z")


Appreciate your help.

Thanks again
 
J

Joel

If host name is over one column from networkdriver then

from
if MyString = "" then
MyString = Table1.Cells(c, 8)
else
MyString = MyString & "," & Table1.Cells(c, 8)
end if

to

if MyString = "" then
MyString = Table1.Cells(c, 7)
else
MyString = MyString & "," & Table1.Cells(c, 7)
end if



I changed the 8 to a 7.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top