Hello, I am using a variable to represent a current file in a folder I am filtering through. I then trimmed that file name to extract the exact name I need to then use as another variable representing a sheet name in another file. In this Sheet for the other file it contains data that I then need to copy and paste onto the first file. I’m using Excel Scope, use excel file, and the dynamic variable that reads as the exact sheet name I am trying to read from. I am using read range and to see if it would read it properly I used a message box to show me the data it is reading. Instead it just shows the sheet name. Instead of reading the data from the existing sheet it creates a new sheet with the exact same name. Why does it keep doing this? Please help!
“Create if not exist” is for the file, not sheets within the file.
What do you mean “trimmed that filename?”
What you’re describing is a fairly simple operation:
- Read Range source file into datatable
- Filter Data Table to remove the data you don’t want
- Write/Append Range to the destination file
dynamic variable that reads as the exact sheet name I am trying to read from
Where is this sheet name coming from?
I used a message box to show me the data it is reading. Instead it just shows the sheet
You can’t just put a datatable into a message box. It’s a complex object. Put a breakpoint on the activity where you want it to pause, and run it in Debug mode. When it gets to the breakpoint it will pause and you can see in Studio the value of all the variables. You can expand your datatable variable and see everything that’s in it.
Are you absolutely sure the sheet name is exactly the same? An extra space or something and it’ll create it as a new sheet.
The sheet name is exactly the same. I’ve also tried the read range then write range into the file I need it, but ofcourse it writes nothing, because it continually just creates a new sheet with the exact same name. What I mean by trim the file name is it has beginning characters and the extension at the end that I remove and then it prints out the part of the file name that I need that matches the sheet name. I’ve used all of these activities before, but without dynamic variables. Using the exact name is of course very easy. The file name and sheet names will always change so hence the difficulty.
Not sure how you’re getting just the filename without extension but this is the easiest way:
System.IO.Path.GetFileNameWithoutExtension(var_FullPathAndFilename)
I’ve also tried the read range then write range into the file I need it
Post screenshots of your code. Something isn’t right, because this is all a very simple thing to do.
And when using the forums, make sure you click Reply for the comment you’re replying to so that person gets a notification.