I have a rather interesting problem going on in my excel problem. Basically I have two Workbooks, lets say
ACTIVE.xlsm and EXTERNAL.xls
Active has a macro that opens external and drops in some data from active, then reads a solution on external and returns it to the user on the active workbook. Whew. Thats a tough one. Now that we're through that, heres the problem. It is my personal opinion that there is a glitch in external (which I'm unable to fix as its a company read-only file) that when active drops in its data into a specific drop-down (data validation) cell (other data validation cells work fine with this macro, its only this one that doesn't), the solution cell on external doesnt update, but rather jumps to "#N/A". At this point, my VBA has run into a bug, and the code stops with external still open. When I look at external, I've deduced that this singular variable cell is the problem amdist all the other variable cells determining the solution.
The variable cell at this point contains the number "150" and although the data validation allows for this option, the solution cell still says "#N/A". It isn't until I physically click inside of the cell with "150" like I'm going to edit it, then I press enter, that the #N/A corrects to the appropriate solution (Let's say this solution is "$352.08") Keep in mind, the value within the variable cell never changed, it perhaps only was "refreshed".
Any ideas as to why this is happening? I know this is long-winded, but I suppose that's why I have been unable to find a solution thus far. Perhaps there's a VBA workaround that can simulate clicking in the cell, then pressing enter, who knows!
Thanks in advance!
Here's some code for funsies, though I don't believe this is a code issue, as it works for all other "external"'s that I've been working with.
...ElseIf Left(Range("C9").Value, 4) = "LA23" Then
CurWkbk = ActiveWorkbook.Name
PartNo = Worksheets("LINAK ONE").Range("C6").Value
PartNoID_B = Worksheets("GPL Pull").Range("B8").Value
PartNoID_C = Worksheets("GPL Pull").Range("C8").Value
PartNoID_D = Worksheets("GPL Pull").Range("D8").Value
PartNoID_E = Worksheets("GPL Pull").Range("E8").Value
PartNoID_F = Worksheets("GPL Pull").Range("F8").Value
PartNoID_G = Worksheets("GPL Pull").Range("G8").Value
PartNoID_H = Worksheets("GPL Pull").Range("H8").Value
PartNoID_I = Worksheets("GPL Pull").Range("I8").Value
PartNoID_J = Worksheets("GPL Pull").Range("J8").Value
PartNoID_K = Worksheets("GPL Pull").Range("K8").Value
Workbooks.Open ("EXTERNAL.xls")
Workbooks("EXTERNAL.xls").Sheets("Price").Activate
Range("E9").Value = PartNoID_B
Range("G9").Value = PartNoID_C
Range("I9").Value = PartNoID_D
Range("K9").Value = PartNoID_E
Range("M9").Value = PartNoID_F
Range("O9").Value = PartNoID_G
Range("Q9").Value = PartNoID_H
Range("S9").Value = PartNoID_I
Range("S9").Select
ActiveCell.Calculate
Range("U9").Value = PartNoID_J
Range("W9").Value = PartNoID_K
Range("AD7").Value = "LUS"
LUSPrice = Range("AE9").Value
Range("AD7").Value = "USD"
USDPrice = Range("AE9").Value
Range("AD7").Value = "DKK"
DKKPrice = Range("AE9").Value
Windows(CurWkbk).Activate
ActiveWorkbook.Sheets("Discount Calculator").Activate
Range("D5").Value = LUSPrice
ActiveWorkbook.Sheets("PRICE GENERATOR").Activate
Range("C25").Value = PartNo & " Pricing | LUS: $" & Round(LUSPrice, 2) & " | USD: $" & Round(USDPrice, 2) & " | DKK: kr " & Round(DKKPrice, 2)
MsgBox "Tillykke! Pricing for the " & PartNo & " has been generated. The price has been entered into the discount calculator.", , "Pricing Generated"
Workbooks("EXTERNAL.xls").Close False...
you should be using fully qualified references to cells
this is a rewrite of your code
...ElseIf Left(Range("C9").Value, 4) = "LA23" Then ' which workbook/sheet ????
CurWkbk = ActiveWorkbook.Name ' which workbook ????
PartNo = Worksheets("LINAK ONE").Range("C6").Value ' which workbook ????
With Worksheets("GPL Pull")
PartNoID_B = .Range("B8").Value
PartNoID_C = .Range("C8").Value
PartNoID_D = .Range("D8").Value
PartNoID_E = .Range("E8").Value
PartNoID_F = .Range("F8").Value
PartNoID_G = .Range("G8").Value
PartNoID_H = .Range("H8").Value
PartNoID_I = .Range("I8").Value
PartNoID_J = .Range("J8").Value
PartNoID_K = .Range("K8").Value
End With
Workbooks.Open ("EXTERNAL.xls")
With Workbooks("EXTERNAL.xls").Worksheets("Price")
.Range("E9").Value = PartNoID_B
.Range("G9").Value = PartNoID_C
.Range("I9").Value = PartNoID_D
.Range("K9").Value = PartNoID_E
.Range("M9").Value = PartNoID_F
.Range("O9").Value = PartNoID_G
.Range("Q9").Value = PartNoID_H
.Range("S9").Value = PartNoID_I
.Range("S9").Calculate
.Range("U9").Value = PartNoID_J
.Range("W9").Value = PartNoID_K
.Range("AD7").Value = "LUS"
LUSPrice = .Range("AE9").Value
.Range("AD7").Value = "USD"
USDPrice = .Range("AE9").Value
.Range("AD7").Value = "DKK"
DKKPrice = .Range("AE9").Value
End With
CurWkbk.Worksheets("Discount Calculator").Range("D5").Value = LUSPrice ' which workbook ????
CurWkbk.Worksheets("PRICE GENERATOR").Range("C25").Value = PartNo & " Pricing | LUS: $" & Round(LUSPrice, 2) & " | USD: $" & Round(USDPrice, 2) & " | DKK: kr " & Round(DKKPrice, 2)
MsgBox "Tillykke! Pricing for the " & PartNo & " has been generated. The price has been entered into the discount calculator.", , "Pricing Generated"
Workbooks("EXTERNAL.xls").Close False...
Related
I have some specific things I need to automatically bold and am having issues coming up with the right code for this... Below is an example:
Product Name:
Customer Account/Name:
Description of Issue:
So, what I need is only bold the above and nothing after the ":", example:
Product Name: Tech Tools
Customer Account/Name: Federation of Planets
Description of Issue: NCC-1701 leaking
So, all of my VBA experience comes from Excel... Which I stupidly started this in excel and then realized that wouldn't work and was like "Oh, I can just use my vba from Excel in Word!" No... no I can't...
Here is my Excel VBA:
Sub Find_and_Bold()
Dim rCell As Range, sToFind As String, iSeek As Long
Dim Text(1 To 33) As String
Dim i As Integer
Text(1) = "Product Name:"
Text(2) = "Project ID and/or URL:"
Text(3) = "Permission to join project?"
Text(4) = "Permission to join Account as Admin?"
Text(5) = "No. of Users on Project:"
Text(6) = "Company/Account Name:"
Text(7) = "Reported by:"
Text(8) = "Reporting User Role in Project:"
Text(9) = "Platform, Version, OS Version:"
Text(10) = "Which platform does this organization/user mainly use?"
Text(11) = "Can the agent repro in test project?"
Text(12) = "Is this related to a third-party integration? (If so, please provide name):"
Text(13) = "What is the company and project name in the third-party software?"
Text(14) = "Has the reporter been able to perform this action with no issues in the past?"
Text(15) = "Pype-Spec Version Name (if applicable):"
Text(16) = "Salesforce ID:"
Text(17) = "Description of Issue:"
Text(18) = "Steps to Reproduce:"
Text(19) = "1."
Text(20) = "2."
Text(21) = "3."
Text(22) = "4."
Text(23) = "Expected Behavior:"
Text(24) = "Observed Behavior"
Text(25) = "Additional Observation/Notes"
Text(26) = "Company/Account name:"
Text(27) = "Can the agent repro in customer project?"
Text(28) = "Is this related to a third party integration?"
Text(29) = "Pype-Spec version name (if applicable):"
Text(30) = "Has the customer provided screenshots/screen- recordings?"
Text(31) = "Description of issue:"
Text(32) = "# of Users on Project:"
Text(33) = "# of Users on Project:"
For Each rCell In Range("A1:A100")
For i = LBound(Text) To UBound(Text)
sToFind = Text(i)
iSeek = InStr(1, rCell.Value, sToFind)
Do While iSeek > 0
rCell.Characters(iSeek, Len(sToFind)).Font.Bold = True
iSeek = InStr(iSeek + 1, rCell.Value, sToFind)
Loop
Next i
Next rCell
Call DeleteBlankRows
End Sub
It seems to me you could do the lot without VBA, just using a wildcard Find/Replace, where:
Find = [!^13]#[:\?.]
Replace = ^&
and:
Find = [!^13][1-4].
Replace = ^&
with the replacement font attribute set to Bold or, better still, to the 'Strong' character Style.
The only string that might be missed is 'Observed Behavior' - because in your code it lacks a terminating ':'.
The above can, of course, be turned into VBA.
I have a dataset that contains multiple values. I want to take those rows from that dataset that contains "the specific value" and firstly I want to display those in a MessageBox.
Furtheron, I try to view them in a datagridview called ErrorsDgV.
I already searched this topic and found a good function, but unfortunately, all I get from the MessageBox is an empty box.
ErrorsDgV.DataSource = Srchdataset.Tables("blubb")
LineLabel.Text = "Lines: " &
Srchdataset.Tables("blubb").Rows.Count.ToString
ErrorsDgV.Sort(ErrorsDgV.Columns(1), System.ComponentModel.ListSortDirection.Ascending)
ErrorsDgV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
ErrorsDgV.Columns(1).DefaultCellStyle.Format = "dd/MM/yyyy HH:mm:ss.fff"
Dim answer As String = ""
Dim SearchRows() As Data.DataRow
SearchRows = Srchdataset.Tables("blubb").Select("Data = 'the specific value'")
answer = ""
For k As Integer = 0 To SearchRows.Length - 1
If answer = "" Then
answer = SearchRows(k).Item("Data")
Else
answer = answer & vbNewLine & SearchRows(k).Item("Data")
End If
Next
MsgBox(" " & answer)
I debugged also and got to know that SearchRows is empty, even if the specific value is inlcuded in that DataSet.
I have the below table in word that I'm trying to write a script to replace the contents of the below cell with a different customer payment (i.e replace the £1,100 with £2,000). Below is a snippet of my script but the when I write back to the cell it loses all the formatting and the numbered list.
How can I keep replace the cell data with very similar data and still keep the formatting?
ps. I've simplified the contents of the cell to make it easier to read, so the code won't apply to exactly that content
DescPlan = Trim(t1.Cell(2, 2).Range.Text)
DescTest = InStr(1, DescPlan, ":")
finalString = Left(DescPlan, DescTest)
t1.Cell(2, 2).Range.Text = Replace(DescPlan, finalString, "Payment by the customer of " + Format(v, "Currency") + " will be due upon completion of items below:")
Not sure if this helps but you are using a table so what works for excel should also work for you.
Sub replace_keep_format()
Dim t1 As Range
Dim sStrng As String, rStrng As String
Dim i As Integer
sStrng = "£1,100"
rStrng = "£2,000"
i = 1
Do Until ThisWorkbook.Sheets(1).Range("a" & i) = ""
Set t1 = ThisWorkbook.Sheets(1).Range("a" & i)
t1 = Replace(Expression:=t1, Find:=sStrng, Replace:=rStrng)
i = i + 1
Loop
End Sub
I need to retrieve only the values from nodes which their attribute are "true". Here's what I have and what I need - appreciate any help:
<AudioTracks>
<original available="true">ENG</original>
<localized available="false">SPA</localized>
<localized available="true">POR</localized>
</AudioTracks>
Here's my code, it will retrieve all values, but I would like to find a way to only retrieve ENG and POR (true). I can't seem to find a suitable way to do it.
'AudioTracks
Set oAudioNodes = featureNode.SelectSingleNode("videos/video/AudioTracks")
For i = 0 To oAudioNodes.ChildNodes.Length
sAudio = oAudioNodes.ChildNodes.Item(i).nodeTypedValue & ";" & sAudio
Next
sAudio = Left(sAudio, Len(sAudio) - 1)
ActiveSheet.Cells(intRow, colAudioTracks).Value = NullCheck(sAudio)
sAudio = ""
sRawData = ""
This will return me ENG;SPA;POR ... But I need it to return only ENG;POR
Help me Obi Wan, you're my only hope.
Eureka. I have found a way to make this happen. Not beautiful but works just fine! I just did a small conditional using the getAttribute property. As a parameter, I have just used the attribute name (in this case "available"). Ha! Beautiful - for me.
Set oAudioNodes = featureNode.SelectSingleNode("videos/video/AudioTracks")
txt = ""
For i = 0 To oAudioNodes.ChildNodes.Length
txt = oAudioNodes.ChildNodes.Item(i).getAttribute("available")
If txt = "true" Then sAudio = oAudioNodes.ChildNodes.Item(i).nodeTypedValue & ";" & sAudio
Next
sAudio = Left(sAudio, Len(sAudio) - 1)
ActiveSheet.Cells(intRow, colAudioTracks).Value = NullCheck(sAudio)
sAudio = ""
sRawData = ""
txt = ""
I have a tool that capture screenshots of the application that we test at our workplace. Now once I complete my testing of a particular test case or scenarios, we attach the screenshot that we have taken to HP Quality Center manually.
I want to automate this and make my tool to upload the word document to a test in QC Test Lab. Is this possible? If Yes, How can we do this in Excel VBA?
Operations that we need to perform would be as below:
Connect to QC project with login credentials, domain & project details
Pick a file(s) from a local folder
Upload a file(s) to QC Test Lab, specific test case
I used the below code, but getting error in that code. I marked it in the code below, please check below :
Dim intTestID, FldPath, TestSetName, i
Dim TestSetFact, tsTreeMgr, tSetFolder, TestSetsList, theTestSet
Dim TestSetIdentifier, TSTestFact, TestSetTestsList, testInstanceF, aFilter
Dim lst, tstInstance
intTestID = "8968"
FldPath = TextBox3.Text '"Root\ProjFold\Release1\BRD"
TestSetName = ComboBox3.Text '"BRD" '
Set Connection = CreateObject("TDApiOle80.TDConnection")
Connection.InitConnectionEx Sheet2.Range("B1").Value2
Connection.Login TextBox1.Text, TextBox2.Text
Connection.Connect ComboBox1.Text, ComboBox2.Text
Set TestSetFact = Connection.TestSetFactory
Set tsTreeMgr = Connection.TestSetTreeManager
Set tSetFolder = tsTreeMgr.NodeByPath(FldPath)
Set TestSetsList = tSetFolder.FindTestSets(TestSetName)
Set theTestSet = TestSetsList.Item(1)
TestSetIdentifier = theTestSet.ID
i = 0
Set TSTestFact = theTestSet.TSTestFactory
Set TestSetTestsList = TSTestFact.NewList("")
Set testInstanceF = Connection.TSTestFactory
Set aFilter = testInstanceF.Filter
aFilter.Filter("TC_TEST_ID") = intTestID
Set lst = testInstanceF.NewList(aFilter.Text)
Set tstInstance = lst.Item(1) <---------------- getting error here
MsgBox (tstInstance.Field("TS_Name"))
'tstInstance.Status = "Failed"
'tstInstance.Field("TC_STATUS") = Item1.Status '"Passed"
'tstInstance.Post
Dim RunF, runName, NewRun, runStepF, runlst, Item1, runStep2
MsgBox (tstInstance.Field("TS_Subject"))
Set RunF = tstInstance.RunFactory
runName = "Run_" & Month(Date) & "-" & Day(Date) & "_" & Hour(Now) & "-" & Minute(Now) & "-" & Second(Now)
Set NewRun = RunF.AddItem(Null)
NewRun.Status = "Passed"
NewRun.Name = runName
NewRun.Post
NewRun.CopyDesignSteps
NewRun.Post
Set runStepF = NewRun.StepFactory
Set runlst = runStepF.NewList("")
For Each Item1 In runlst
Set runStep2 = Item1
runStep2.Status = "Passed" '
runStep2.Field("ST_ACTUAL") = "As Expected"
runStep2.Post
Next
'tstInstance.Refresh
tstInstance.Status = "Failed"
tstInstance.Post
Connection.DisconnectProject
Connection.ReleaseConnection
'Set QC = Nothing
Set Connection = Nothing
The error is occurring because the array of objects is not returning. You need to check if the Filter gives you a list of results before assuming that lst.Item(1) exists.
For instance:
If lst.Count > 0 Then Set tstInstance = lst.Item(1)