Click here to Skip to main content
15,916,463 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSplit cells with comma and space Pin
manju 34-Feb-19 21:34
manju 34-Feb-19 21:34 
QuestionRe: Split cells with comma and space Pin
Richard MacCutchan4-Feb-19 22:11
mveRichard MacCutchan4-Feb-19 22:11 
AnswerRe: Split cells with comma and space Pin
manju 34-Feb-19 23:47
manju 34-Feb-19 23:47 
GeneralRe: Split cells with comma and space Pin
Richard MacCutchan4-Feb-19 23:56
mveRichard MacCutchan4-Feb-19 23:56 
GeneralRe: Split cells with comma and space Pin
Richard Deeming5-Feb-19 1:17
mveRichard Deeming5-Feb-19 1:17 
AnswerRe: Split cells with comma and space Pin
Maciej Los5-Feb-19 1:41
mveMaciej Los5-Feb-19 1:41 
Questiondatagridview that was bound to dataset Pin
ClintSoft4-Feb-19 15:38
ClintSoft4-Feb-19 15:38 
QuestionLoad xlsx filr from folder and write to new workbook Pin
manju 33-Feb-19 20:25
manju 33-Feb-19 20:25 
Hi all,

I need to load an Test.xlxs file form "D" drive and write the same content to new workbook in sheet1.
Add sheet2 in the workbook and filter the workbook and write the filtered into sheet2 to on workbook.

I have tried the below code but its writing to the same input file with sheet2 but not in the new workbook.

Input file will contain
DrinkID	Reciepe_Dat
2	Absolute,Enter,Test
3	Decupper,Enter,Test
4	"Absolute
"


Output is having
DrinkID	Reciepe_Dat
2	Absolute
2	Enter
2	Test
3	Decupper
3	Enter
3	Test
4	"Absolute
"


but writing to the same input file.

here is my code:
Sub splitbycells()
Dim splitvals As Variant
Dim totalVals As Long

Set sh1 = ThisWorkbook.Sheets(1)
Set sh2 = ThisWorkbook.Sheets(2)

sh2.Cells.Clear
lrow1 = sh1.Range("A65356").End(xlUp).Row

For j = 2 To lrow1
    'splitvals = Split(sh1.Cells(j, 2), Chr(10))
    splitvals = Split(sh1.Cells(j, 2), ",")
    
    For i = LBound(splitvals) To UBound(splitvals)
        lrow2 = sh2.Range("B65356").End(xlUp).Row
        lrow3 = sh2.Range("A65356").End(xlUp).Row
        sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
        sh2.Cells(lrow3 + 1, 2) = splitvals(i)
    Next i
Next j
sh2.Range("A1") = "DrinkID"
sh2.Range("B1") = "Reciepe_Dat"
        

End Sub


Thanks
Sharan
QuestionRe: Load xlsx filr from folder and write to new workbook Pin
Richard MacCutchan3-Feb-19 22:23
mveRichard MacCutchan3-Feb-19 22:23 
AnswerRe: Load xlsx filr from folder and write to new workbook Pin
manju 34-Feb-19 21:39
manju 34-Feb-19 21:39 
GeneralRe: Load xlsx filr from folder and write to new workbook Pin
Richard MacCutchan4-Feb-19 22:00
mveRichard MacCutchan4-Feb-19 22:00 
GeneralRe: Load xlsx filr from folder and write to new workbook Pin
manju 34-Feb-19 23:49
manju 34-Feb-19 23:49 
QuestionMacro Substitution en VB.Net Pin
Member 141390043-Feb-19 17:00
Member 141390043-Feb-19 17:00 
AnswerRe: Macro Substitution en VB.Net Pin
Eddy Vluggen3-Feb-19 22:45
professionalEddy Vluggen3-Feb-19 22:45 
GeneralRe: Macro Substitution en VB.Net Pin
Member 141390049-Feb-19 13:24
Member 141390049-Feb-19 13:24 
GeneralRe: Macro Substitution en VB.Net Pin
Member 141390043-Mar-19 6:18
Member 141390043-Mar-19 6:18 
GeneralRe: Macro Substitution en VB.Net Pin
Eddy Vluggen3-Mar-19 6:28
professionalEddy Vluggen3-Mar-19 6:28 
AnswerRe: Macro Substitution en VB.Net Pin
Maciej Los5-Feb-19 2:38
mveMaciej Los5-Feb-19 2:38 
GeneralRe: Macro Substitution en VB.Net Pin
Member 141390049-Feb-19 13:25
Member 141390049-Feb-19 13:25 
GeneralRe: Macro Substitution en VB.Net Pin
Member 141390043-Mar-19 6:17
Member 141390043-Mar-19 6:17 
QuestionCompute Sum on a column based on criteria Pin
Member 1412885424-Jan-19 6:54
Member 1412885424-Jan-19 6:54 
AnswerRe: Compute Sum on a column based on criteria Pin
Richard Deeming24-Jan-19 8:41
mveRichard Deeming24-Jan-19 8:41 
GeneralRe: Compute Sum on a column based on criteria Pin
Member 1412885424-Jan-19 17:47
Member 1412885424-Jan-19 17:47 
QuestionRe: Compute Sum on a column based on criteria Pin
Ralf Meier24-Jan-19 19:58
mveRalf Meier24-Jan-19 19:58 
AnswerRe: Compute Sum on a column based on criteria Pin
Member 1412885424-Jan-19 21:07
Member 1412885424-Jan-19 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.