hy
- User
hy
- Assistant
Hello! How can I assist you today?
- User
i need some vba code
- Assistant
Of course! I'd be happy to help with some VBA (Visual Basic for Applications) code. Could you please provide more details about what you need? For example:
- Are you working with Excel, Access, Word, or another application?
- What specific task or problem are you trying to solve with VBA?
- Any particular elements, such as workbooks, sheets, ranges, tables, or forms, that you’re working with?
This information will help me provide the most relevant code for your needs.
- User
in an excel file with a sheet called "Sheet1" in column C there are numerical values and text, for numerical values add 5 and write the result obtained in column I, multiply the result in column I with the numerical values in column A and write the result in column J without deleting or modifying the values in column I, and for columns C, F.G.H calculate the sum for each column separately and write the result in the last cell that contains a value from these columns, also write above the first value in column I "WITH ADDITION", the same for column J and it says "TOTAL MATERIAL".
- Assistant
- User
REPLACE "WITH ADDITION " WITH "CU ADAOS"
- Assistant
Certainly! Below is the updated VBA code with "WITH ADDITION" replaced by "CU ADAOS":
Sub UpdateValues() Dim ws As Worksheet Dim lastRow As Long Dim i As Long Dim sumC As Double, sumF As Double, sumG As Double, sumH As Double Set ws = ThisWorkbook.Sheets("Sheet1") ' Find the last row with data in column C lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row ' Insert headers in columns I and J ws.Range("I1").Value = "CU ADAOS" ws.Range("J1").Value = "TOTAL MATERIAL" ' Iterate through each row in columns A and C For i = 2 To lastRow If IsNumeric(ws.Cells(i, "C").Value) Then ws.Cells(i, "I").Value = ws.Cells(i, "C").Value + 5 ws.Cells(i, "J").Value = ws.Cells(i, "I").Value * ws.Cells(i, "A").Value End If Next i ' Sum the values in columns C, F, G, H sumC = Application.WorksheetFunction.Sum(ws.Range("C2:C" & lastRow)) sumF = Application.WorksheetFunction.Sum(ws.Range("F2:F" & lastRow)) sumG = Application.WorksheetFunction.Sum(ws.Range("G2:G" & lastRow)) sumH = Application.WorksheetFunction.Sum(ws.Range("H2:H" & lastRow)) ' Write the sums to the last cells with values in columns C, F, G, H ws.Cells(ws.Cells(ws.Rows.Count, "C").End(xlUp).Row + 1, "C").Value = sumC ws.Cells(ws.Cells(ws.Rows.Count, "F").End(xlUp).Row + 1, "F").Value = sumF ws.Cells(ws.Cells(ws.Rows.Count, "G").End(xlUp).Row + 1, "G").Value = sumG ws.Cells(ws.Cells(ws.Rows.Count, "H").End(xlUp).Row + 1, "H").Value = sumH End Sub - User
OK FOR THIS CODE I WANT TO MODIFY THIS : AFTER YOU CALCULATE VALUE FOR COLUMN J DIVIDE THIS VALUE BY 100 AND AFTER THAT WRITE REZULT IN COLUM J
- Assistant
Sure, I can update the code to include an additional step: dividing the value of column J by 100 before writing it to column J.
Here is the modified code:
Sub UpdateValues() Dim ws As Worksheet Dim lastRow As Long Dim i As Long Dim sumC As Double, sumF As Double, sumG As Double, sumH As Double Set ws = ThisWorkbook.Sheets("Sheet1") ' Find the last row with data in column C lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row ' Insert headers in columns I and J ws.Range("I1").Value = "CU ADAOS" ws.Range("J1").Value = "TOTAL MATERIAL" ' Iterate through each row in columns A and C For i = 2 To lastRow If IsNumeric(ws.Cells(i, "C").Value) Then ws.Cells(i, "I").Value = ws.Cells(i, "C").Value + 5 ws.Cells(i, "J").Value = (ws.Cells(i, "I").Value * ws.Cells(i, "A").Value) / 100 End If Next i ' Sum the values in columns C, F, G, H sumC = Application.WorksheetFunction.Sum(ws.Range("C2:C" & lastRow)) sumF = Application.WorksheetFunction.Sum(ws.Range("F2:F" & lastRow)) sumG = Application.WorksheetFunction.Sum(ws.Range("G2:G" & lastRow)) sumH = Application.WorksheetFunction.Sum(ws.Range("H2:H" & lastRow)) ' Write the sums to the last cells with values in columns C, F, G, H ws.Cells(ws.Cells(ws.Rows.Count, "C").End(xlUp).Row + 1, "C").Value = sumC ws.Cells(ws.Cells(ws.Rows.Count, "F").End(xlUp).Row + 1, "F").Value = sumF ws.Cells(ws.Cells(ws.Rows.Count, "G").End(xlUp).Row + 1, "G").Value = sumG ws.Cells(ws.Cells(ws.Rows.Count, "H").End(xlUp).Row + 1, "H").Value = sumH End Sub - User
OK NOW I WNT TO TRANSFORM SOME PDF IN TXT WITH PHYTON AND TO USE THAT FUNCTION LIKA AN VBA IN EXCEL
- Assistant
- User
OK PATH FOR PHYTON SCRIPT IS C:\phyton script and name of phyton script is pdf_to_text.py, as for pdf i want to convert pdf to text for pdf that are found in path writed on Sheet2 column B ROW 2
- Assistant
- User
HOW TO INSTALL PDF PLUMBER AND SYS
- Assistant
- User
shellResult = Shell(command, vbNormalFocus) ERROR
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.